PluginProbe
Authorizer / 3.9.1
Authorizer v3.9.1
3.16.0 3.15.3 3.15.2 3.15.1 3.15.0 3.14.3 3.14.4 3.14.2 3.14.1 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.10 2.9.11 2.9.12 2.9.13 2.9.2 2.9.3 All 127 releases
← All changes | js/authorizer.js +134 -268 3.15.13.9.1 View file →
@@ -207,9 +207,9 @@
207 207 for ( var i = 0; i < response.invalid_emails.length; i++ ) {
208 208 var duplicateEmail = response.invalid_emails[i];
209 209 $( 'li.new-user .auth-email[value="' + duplicateEmail + '"]' )
210 210 .siblings( '.spinner' ).addClass( 'duplicate' ).append( '<span class="spinner-text"><span class="attention">' + authL10n.duplicate + '.</span></span>' )
211 - .parent().fadeOut( 2000, function() { $( this ).remove(); }); // jshint ignore:line
211 + .parent().fadeOut( spinnerWait, function() { $( this ).remove(); }); // jshint ignore:line
212 212 }
213 213 }
214 214
215 215 // Show message ('Saved', 'Failed', or 'Saved, removing duplicates').
@@ -373,9 +373,8 @@
373 373 $( document ).ready( function() {
374 374 // Grab references to form elements that we will show/hide on page load
375 375 /* eslint-disable camelcase */
376 376 var auth_settings_access_role_receive_pending_emails = $( '#auth_settings_access_role_receive_pending_emails' ).closest( 'tr' );
377 - var auth_settings_access_users_receive_pending_emails = $( '#auth_settings_access_users_receive_pending_emails' ).closest( 'tr' );
378 377 var auth_settings_access_pending_redirect_to_message = $( '#wp-auth_settings_access_pending_redirect_to_message-wrap' ).closest( 'tr' );
379 378 var auth_settings_access_blocked_redirect_to_message = $( '#wp-auth_settings_access_blocked_redirect_to_message-wrap' ).closest( 'tr' );
380 379 var auth_settings_access_should_email_approved_users = $( '#auth_settings_access_should_email_approved_users' ).closest( 'tr' );
381 380 var auth_settings_access_email_approved_users_subject = $( '#auth_settings_access_email_approved_users_subject' ).closest( 'tr' );
@@ -383,85 +382,33 @@
383 382 var auth_settings_access_public_pages = $( '#auth_settings_access_public_pages' ).closest( 'tr' );
384 383 var auth_settings_access_redirect_to_login = $( '#radio_auth_settings_access_redirect_to_login' ).closest( 'tr' );
385 384 var auth_settings_access_public_warning = $( '#radio_auth_settings_access_public_warning' ).closest( 'tr' );
386 385 var auth_settings_access_redirect_to_message = $( '#wp-auth_settings_access_redirect_to_message-wrap' ).closest( 'tr' );
386 + var auth_settings_external_oauth2_provider = $( '#auth_settings_oauth2_provider' ).closest( 'tr' );
387 + var auth_settings_external_oauth2_custom_label = $( '#auth_settings_oauth2_custom_label' ).closest( 'tr' );
388 + var auth_settings_external_oauth2_clientid = $( '#auth_settings_oauth2_clientid' ).closest( 'tr' );
389 + var auth_settings_external_oauth2_clientsecret = $( '#auth_settings_oauth2_clientsecret' ).closest( 'tr' );
390 + var auth_settings_external_oauth2_hosteddomain = $( '#auth_settings_oauth2_hosteddomain' ).closest( 'tr' );
391 + var auth_settings_external_oauth2_tenant_id = $( '#auth_settings_oauth2_tenant_id' ).closest( 'tr' );
392 + var auth_settings_external_oauth2_url_authorize = $( '#auth_settings_oauth2_url_authorize' ).closest( 'tr' );
393 + var auth_settings_external_oauth2_url_token = $( '#auth_settings_oauth2_url_token' ).closest( 'tr' );
394 + var auth_settings_external_oauth2_url_resource = $( '#auth_settings_oauth2_url_resource' ).closest( 'tr' );
387 395 var auth_settings_external_oauth2_auto_login = $( '#auth_settings_oauth2_auto_login' ).closest( 'tr' );
388 - var auth_settings_external_oauth2_num_servers = $( '#auth_settings_oauth2_num_servers' ).closest( 'tr' );
389 - var auth_settings_external_oauth2_servers = [];
390 - // OAuth2 settings below are for the first configured OAuth2 server.
391 - auth_settings_external_oauth2_servers.push( {
392 - provider: $( '#auth_settings_oauth2_provider' ).closest( 'tr' ),
393 - custom_label: $( '#auth_settings_oauth2_custom_label' ).closest( 'tr' ),
394 - clientid: $( '#auth_settings_oauth2_clientid' ).closest( 'tr' ),
395 - clientsecret: $( '#auth_settings_oauth2_clientsecret' ).closest( 'tr' ),
396 - hosteddomain: $( '#auth_settings_oauth2_hosteddomain' ).closest( 'tr' ),
397 - tenant_id: $( '#auth_settings_oauth2_tenant_id' ).closest( 'tr' ),
398 - url_authorize: $( '#auth_settings_oauth2_url_authorize' ).closest( 'tr' ),
399 - url_token: $( '#auth_settings_oauth2_url_token' ).closest( 'tr' ),
400 - url_resource: $( '#auth_settings_oauth2_url_resource' ).closest( 'tr' ),
401 - attr_username: $( '#auth_settings_oauth2_attr_username' ).closest( 'tr' ),
402 - attr_email: $( '#auth_settings_oauth2_attr_email' ).closest( 'tr' ),
403 - attr_first_name: $( '#auth_settings_oauth2_attr_first_name' ).closest( 'tr' ),
404 - attr_last_name: $( '#auth_settings_oauth2_attr_last_name' ).closest( 'tr' ),
405 - attr_update_on_login: $( '#auth_settings_oauth2_attr_update_on_login' ).closest( 'tr' ),
406 - link_on_username: $( '#auth_settings_oauth2_link_on_username' ).closest( 'tr' ),
407 - } );
408 - // OAuth2 settings below are for any additional OAuth2 servers configured (up to 20).
409 - for ( var i = 2; i <= parseInt( $( '#auth_settings_oauth2_num_servers' ).val() ) && i <= 20; i++ ) {
410 - auth_settings_external_oauth2_servers.push( {
411 - provider: $( '#auth_settings_oauth2_provider_' + i ).closest( 'tr' ),
412 - custom_label: $( '#auth_settings_oauth2_custom_label_' + i ).closest( 'tr' ),
413 - clientid: $( '#auth_settings_oauth2_clientid_' + i ).closest( 'tr' ),
414 - clientsecret: $( '#auth_settings_oauth2_clientsecret_' + i ).closest( 'tr' ),
415 - hosteddomain: $( '#auth_settings_oauth2_hosteddomain_' + i ).closest( 'tr' ),
416 - tenant_id: $( '#auth_settings_oauth2_tenant_id_' + i ).closest( 'tr' ),
417 - url_authorize: $( '#auth_settings_oauth2_url_authorize_' + i ).closest( 'tr' ),
418 - url_token: $( '#auth_settings_oauth2_url_token_' + i ).closest( 'tr' ),
419 - url_resource: $( '#auth_settings_oauth2_url_resource_' + i ).closest( 'tr' ),
420 - attr_username: $( '#auth_settings_oauth2_attr_username_' + i ).closest( 'tr' ),
421 - attr_email: $( '#auth_settings_oauth2_attr_email_' + i ).closest( 'tr' ),
422 - attr_first_name: $( '#auth_settings_oauth2_attr_first_name_' + i ).closest( 'tr' ),
423 - attr_last_name: $( '#auth_settings_oauth2_attr_last_name_' + i ).closest( 'tr' ),
424 - attr_update_on_login: $( '#auth_settings_oauth2_attr_update_on_login_' + i ).closest( 'tr' ),
425 - link_on_username: $( '#auth_settings_oauth2_link_on_username_' + i ).closest( 'tr' ),
426 - } );
427 - }
428 396 var auth_settings_external_google_clientid = $( '#auth_settings_google_clientid' ).closest( 'tr' );
429 397 var auth_settings_external_google_clientsecret = $( '#auth_settings_google_clientsecret' ).closest( 'tr' );
430 398 var auth_settings_external_google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).closest( 'tr' );
431 399 var auth_settings_external_cas_auto_login = $( '#auth_settings_cas_auto_login' ).closest( 'tr' );
432 - var auth_settings_external_cas_num_servers = $( '#auth_settings_cas_num_servers' ).closest( 'tr' );
433 - var auth_settings_external_cas_servers = [];
434 - // CAS settings below are for the first configured CAS server.
435 - auth_settings_external_cas_servers.push( {
436 - custom_label: $( '#auth_settings_cas_custom_label' ).closest( 'tr' ),
437 - host: $( '#auth_settings_cas_host' ).closest( 'tr' ),
438 - port: $( '#auth_settings_cas_port' ).closest( 'tr' ),
439 - path: $( '#auth_settings_cas_path' ).closest( 'tr' ),
440 - method: $( '#auth_settings_cas_method' ).closest( 'tr' ),
441 - version: $( '#auth_settings_cas_version' ).closest( 'tr' ),
442 - attr_email: $( '#auth_settings_cas_attr_email' ).closest( 'tr' ),
443 - attr_first_name: $( '#auth_settings_cas_attr_first_name' ).closest( 'tr' ),
444 - attr_last_name: $( '#auth_settings_cas_attr_last_name' ).closest( 'tr' ),
445 - attr_update_on_login: $( '#auth_settings_cas_attr_update_on_login' ).closest( 'tr' ),
446 - link_on_username: $( '#auth_settings_cas_link_on_username' ).closest( 'tr' ),
447 - } );
448 - // CAS settings below are for any additional CAS servers configured (up to 10).
449 - for ( var i = 2; i <= parseInt( $( '#auth_settings_cas_num_servers' ).val() ) && i <= 10; i++ ) {
450 - auth_settings_external_cas_servers.push( {
451 - custom_label: $( '#auth_settings_cas_custom_label_' + i ).closest( 'tr' ),
452 - host: $( '#auth_settings_cas_host_' + i ).closest( 'tr' ),
453 - port: $( '#auth_settings_cas_port_' + i ).closest( 'tr' ),
454 - path: $( '#auth_settings_cas_path_' + i ).closest( 'tr' ),
455 - method: $( '#auth_settings_cas_method_' + i ).closest( 'tr' ),
456 - version: $( '#auth_settings_cas_version_' + i ).closest( 'tr' ),
457 - attr_email: $( '#auth_settings_cas_attr_email_' + i ).closest( 'tr' ),
458 - attr_first_name: $( '#auth_settings_cas_attr_first_name_' + i ).closest( 'tr' ),
459 - attr_last_name: $( '#auth_settings_cas_attr_last_name_' + i ).closest( 'tr' ),
460 - attr_update_on_login: $( '#auth_settings_cas_attr_update_on_login_' + i ).closest( 'tr' ),
461 - link_on_username: $( '#auth_settings_cas_link_on_username_' + i ).closest( 'tr' ),
462 - } );
463 - }
400 + var auth_settings_external_cas_custom_label = $( '#auth_settings_cas_custom_label' ).closest( 'tr' );
401 + var auth_settings_external_cas_host = $( '#auth_settings_cas_host' ).closest( 'tr' );
402 + var auth_settings_external_cas_port = $( '#auth_settings_cas_port' ).closest( 'tr' );
403 + var auth_settings_external_cas_path = $( '#auth_settings_cas_path' ).closest( 'tr' );
404 + var auth_settings_external_cas_method = $( '#auth_settings_cas_method' ).closest( 'tr' );
405 + var auth_settings_external_cas_version = $( '#auth_settings_cas_version' ).closest( 'tr' );
406 + var auth_settings_external_cas_attr_email = $( '#auth_settings_cas_attr_email' ).closest( 'tr' );
407 + var auth_settings_external_cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).closest( 'tr' );
408 + var auth_settings_external_cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).closest( 'tr' );
409 + var auth_settings_external_cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).closest( 'tr' );
410 + var auth_settings_external_cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).closest( 'tr' );
464 411 var auth_settings_external_ldap_host = $( '#auth_settings_ldap_host' ).closest( 'tr' );
465 412 var auth_settings_external_ldap_port = $( '#auth_settings_ldap_port' ).closest( 'tr' );
466 413 var auth_settings_external_ldap_search_base = $( '#auth_settings_ldap_search_base' ).closest( 'tr' );
467 414 var auth_settings_external_ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).closest( 'tr' );
@@ -474,15 +421,13 @@
474 421 var auth_settings_external_ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).closest( 'tr' );
475 422 var auth_settings_external_ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).closest( 'tr' );
476 423 var auth_settings_external_ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).closest( 'tr' );
477 424 var auth_settings_external_ldap_test_user = $( '#auth_settings_ldap_test_user' ).closest( 'tr' );
478 - var auth_settings_advanced_disable_wp_login_bypass_usernames = $( '#auth_settings_advanced_disable_wp_login_bypass_usernames' ).closest( 'tr' );
479 425 /* eslint-enable */
480 426
481 427 // Hide settings unless "Only approved users" is checked
482 428 if ( ! $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ) {
483 429 animateOption( 'hide_immediately', auth_settings_access_role_receive_pending_emails );
484 - animateOption( 'hide_immediately', auth_settings_access_users_receive_pending_emails );
485 430 animateOption( 'hide_immediately', auth_settings_access_pending_redirect_to_message );
486 431 animateOption( 'hide_immediately', auth_settings_access_blocked_redirect_to_message );
487 432 animateOption( 'hide_immediately', auth_settings_access_should_email_approved_users );
488 433 }
@@ -500,45 +445,76 @@
500 445 animateOption( 'hide_immediately', auth_settings_access_public_warning );
501 446 animateOption( 'hide_immediately', auth_settings_access_redirect_to_message );
502 447 }
503 448
504 - // Hide External Service tabs if provider is unchecked.
505 - $( '.nav-tab-wrapper .nav-tab-external_oauth2' ).toggle( $( '#auth_settings_oauth2' ).is( ':checked' ) );
506 - $( '.nav-tab-wrapper .nav-tab-external_oidc' ).toggle( $( '#auth_settings_oidc' ).is( ':checked' ) );
507 - $( '.nav-tab-wrapper .nav-tab-external_google' ).toggle( $( '#auth_settings_google' ).is( ':checked' ) );
508 - $( '.nav-tab-wrapper .nav-tab-external_cas' ).toggle( $( '#auth_settings_cas' ).is( ':checked' ) );
509 - $( '.nav-tab-wrapper .nav-tab-external_ldap' ).toggle( $( '#auth_settings_ldap' ).is( ':checked' ) );
449 + // Hide OAuth2 options if unchecked.
450 + if ( ! $( '#auth_settings_oauth2' ).is( ':checked' ) ) {
451 + animateOption( 'hide_immediately', auth_settings_external_oauth2_provider );
452 + animateOption( 'hide_immediately', auth_settings_external_oauth2_custom_label );
453 + animateOption( 'hide_immediately', auth_settings_external_oauth2_clientid );
454 + animateOption( 'hide_immediately', auth_settings_external_oauth2_clientsecret );
455 + animateOption( 'hide_immediately', auth_settings_external_oauth2_hosteddomain );
456 + animateOption( 'hide_immediately', auth_settings_external_oauth2_auto_login );
457 + }
510 458
511 - // Hide some OAuth2 options based on current settings.
512 - auth_settings_external_oauth2_servers.forEach( function( server ) {
513 - // Hide OAuth2 generic options if OAuth2 provider is unchecked or generic isn't chosen.
514 - if ( 'generic' !== server.provider.find( 'select' ).val() ) {
515 - animateOption( 'hide_immediately', server.url_authorize );
516 - animateOption( 'hide_immediately', server.url_token );
517 - animateOption( 'hide_immediately', server.url_resource );
518 - animateOption( 'hide_immediately', server.attr_username );
519 - animateOption( 'hide_immediately', server.attr_email );
520 - animateOption( 'hide_immediately', server.attr_first_name );
521 - animateOption( 'hide_immediately', server.attr_last_name );
522 - animateOption( 'hide_immediately', server.attr_update_on_login );
523 - }
524 - // Hide OAuth2 Tenant ID if OAuth2 provider is unchecked or azure isn't chosen.
525 - if ( 'azure' !== server.provider.find( 'select' ).val() ) {
526 - animateOption( 'hide_immediately', server.tenant_id );
527 - }
528 - } );
459 + // Hide OAuth2 generic options if generic isn't chosen.
460 + if ( ! $( '#auth_settings_oauth2' ).is( ':checked' ) || 'generic' !== $( '#auth_settings_oauth2_provider' ).val() ) {
461 + animateOption( 'hide_immediately', auth_settings_external_oauth2_url_authorize );
462 + animateOption( 'hide_immediately', auth_settings_external_oauth2_url_token );
463 + animateOption( 'hide_immediately', auth_settings_external_oauth2_url_resource );
464 + }
529 465
530 - // Hide Bypass Usernames if Disable WordPress logins is unchecked.
531 - if ( ! $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ) {
532 - animateOption( 'hide_immediately', auth_settings_advanced_disable_wp_login_bypass_usernames );
466 + // Hide OAuth2 Tenant ID if azure isn't chosen.
467 + if ( ! $( '#auth_settings_oauth2' ).is( ':checked' ) || 'azure' !== $( '#auth_settings_oauth2_provider' ).val() ) {
468 + animateOption( 'hide_immediately', auth_settings_external_oauth2_tenant_id );
533 469 }
534 470
471 + // Hide Google options if unchecked
472 + if ( ! $( '#auth_settings_google' ).is( ':checked' ) ) {
473 + animateOption( 'hide_immediately', auth_settings_external_google_clientid );
474 + animateOption( 'hide_immediately', auth_settings_external_google_clientsecret );
475 + animateOption( 'hide_immediately', auth_settings_external_google_hosteddomain );
476 + }
477 +
478 + // Hide CAS options if unchecked
479 + if ( ! $( '#auth_settings_cas' ).is( ':checked' ) ) {
480 + animateOption( 'hide_immediately', auth_settings_external_cas_auto_login );
481 + animateOption( 'hide_immediately', auth_settings_external_cas_custom_label );
482 + animateOption( 'hide_immediately', auth_settings_external_cas_host );
483 + animateOption( 'hide_immediately', auth_settings_external_cas_port );
484 + animateOption( 'hide_immediately', auth_settings_external_cas_path );
485 + animateOption( 'hide_immediately', auth_settings_external_cas_method );
486 + animateOption( 'hide_immediately', auth_settings_external_cas_version );
487 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_email );
488 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_first_name );
489 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_last_name );
490 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_update_on_login );
491 + animateOption( 'hide_immediately', auth_settings_external_cas_link_on_username );
492 + }
493 +
494 + // Hide LDAP options if unchecked
495 + if ( ! $( '#auth_settings_ldap' ).is( ':checked' ) ) {
496 + animateOption( 'hide_immediately', auth_settings_external_ldap_host );
497 + animateOption( 'hide_immediately', auth_settings_external_ldap_port );
498 + animateOption( 'hide_immediately', auth_settings_external_ldap_search_base );
499 + animateOption( 'hide_immediately', auth_settings_external_ldap_search_filter );
500 + animateOption( 'hide_immediately', auth_settings_external_ldap_uid );
501 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_email );
502 + animateOption( 'hide_immediately', auth_settings_external_ldap_user );
503 + animateOption( 'hide_immediately', auth_settings_external_ldap_password );
504 + animateOption( 'hide_immediately', auth_settings_external_ldap_tls );
505 + animateOption( 'hide_immediately', auth_settings_external_ldap_lostpassword_url );
506 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_first_name );
507 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_last_name );
508 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_update_on_login );
509 + animateOption( 'hide_immediately', auth_settings_external_ldap_test_user );
510 + }
511 +
535 512 // Event handler: Hide "Handle unauthorized visitors" option if access is granted to "Everyone"
536 513 $( 'input[name="auth_settings[access_who_can_login]"]' ).on( 'change', function() {
537 514 // Hide settings unless "Only approved users" is checked
538 515 var action = $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ? 'show' : 'hide';
539 516 animateOption( action, auth_settings_access_role_receive_pending_emails );
540 - animateOption( action, auth_settings_access_users_receive_pending_emails );
541 517 animateOption( action, auth_settings_access_pending_redirect_to_message );
542 518 animateOption( action, auth_settings_access_blocked_redirect_to_message );
543 519 animateOption( action, auth_settings_access_should_email_approved_users );
544 520 action = action === 'show' && $( '#auth_settings_access_should_email_approved_users' ).is( ':checked' ) ? 'show' : 'hide_immediately';
@@ -561,54 +537,71 @@
561 537 animateOption( action, auth_settings_access_public_pages );
562 538 animateOption( action, auth_settings_access_public_warning );
563 539 });
564 540
565 - // Event handler: Show/hide OAuth2 tab based on checkbox.
541 + // Event handler: Show/hide OAuth2 options based on checkbox.
566 542 $( 'input[name="auth_settings[oauth2]"]' ).on( 'change', function() {
567 - $( '.nav-tab-wrapper .nav-tab-external_oauth2' ).toggle( $( this ).is( ':checked' ) );
543 + var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
544 + animateOption( action, auth_settings_external_oauth2_provider );
545 + animateOption( action, auth_settings_external_oauth2_custom_label );
546 + animateOption( action, auth_settings_external_oauth2_clientid );
547 + animateOption( action, auth_settings_external_oauth2_clientsecret );
548 + animateOption( action, auth_settings_external_oauth2_hosteddomain );
549 + animateOption( action, auth_settings_external_oauth2_auto_login );
568 550 });
569 551
570 - // Event handler: Show/hide OAuth2 generic/azure options based on provider.
571 - auth_settings_external_oauth2_servers.forEach( function( server ) {
572 - server.provider.find( 'select' ).on( 'change', function() {
573 - var action = 'generic' === $( this ).val() ? 'show' : 'hide';
574 - animateOption( action, server.url_authorize );
575 - animateOption( action, server.url_token );
576 - animateOption( action, server.url_resource );
577 - animateOption( action, server.attr_username );
578 - animateOption( action, server.attr_email );
579 - animateOption( action, server.attr_first_name );
580 - animateOption( action, server.attr_last_name );
581 - animateOption( action, server.attr_update_on_login );
582 - action = 'azure' === $( this ).val() ? 'show' : 'hide';
583 - animateOption( action, server.tenant_id );
584 - });
552 + // Event handler: Show/hide OAuth2 generic options based on provider.
553 + $( 'select[name="auth_settings[oauth2_provider]"]' ).on( 'change', function() {
554 + var action = 'generic' === $( this ).val() ? 'show' : 'hide';
555 + animateOption( action, auth_settings_external_oauth2_url_authorize );
556 + animateOption( action, auth_settings_external_oauth2_url_token );
557 + animateOption( action, auth_settings_external_oauth2_url_resource );
558 + action = 'azure' === $( this ).val() ? 'show' : 'hide';
559 + animateOption( action, auth_settings_external_oauth2_tenant_id );
585 560 });
586 561
587 - // Event handler: Show/hide OIDC tab based on checkbox
588 - $( 'input[name="auth_settings[oidc]"]' ).on( 'change', function() {
589 - $( '.nav-tab-wrapper .nav-tab-external_oidc' ).toggle( $( this ).is( ':checked' ) );
590 - });
591 -
592 - // Event handler: Show/hide Google tab based on checkbox
562 + // Event handler: Show/hide Google options based on checkbox
593 563 $( 'input[name="auth_settings[google]"]' ).on( 'change', function() {
594 - $( '.nav-tab-wrapper .nav-tab-external_google' ).toggle( $( this ).is( ':checked' ) );
564 + var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
565 + animateOption( action, auth_settings_external_google_clientid );
566 + animateOption( action, auth_settings_external_google_clientsecret );
567 + animateOption( action, auth_settings_external_google_hosteddomain );
595 568 });
596 569
597 - // Event handler: Show/hide CAS tab based on checkbox
570 + // Event handler: Show/hide CAS options based on checkbox
598 571 $( 'input[name="auth_settings[cas]"]' ).on( 'change', function() {
599 - $( '.nav-tab-wrapper .nav-tab-external_cas' ).toggle( $( this ).is( ':checked' ) );
572 + var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
573 + animateOption( action, auth_settings_external_cas_auto_login );
574 + animateOption( action, auth_settings_external_cas_custom_label );
575 + animateOption( action, auth_settings_external_cas_host );
576 + animateOption( action, auth_settings_external_cas_port );
577 + animateOption( action, auth_settings_external_cas_path );
578 + animateOption( action, auth_settings_external_cas_method );
579 + animateOption( action, auth_settings_external_cas_version );
580 + animateOption( action, auth_settings_external_cas_attr_email );
581 + animateOption( action, auth_settings_external_cas_attr_first_name );
582 + animateOption( action, auth_settings_external_cas_attr_last_name );
583 + animateOption( action, auth_settings_external_cas_attr_update_on_login );
584 + animateOption( action, auth_settings_external_cas_link_on_username );
600 585 });
601 586
602 - // Event handler: Show/hide LDAP tab based on checkbox
587 + // Event handler: Show/hide LDAP options based on checkbox
603 588 $( 'input[name="auth_settings[ldap]"]' ).on( 'change', function() {
604 - $( '.nav-tab-wrapper .nav-tab-external_ldap' ).toggle( $( this ).is( ':checked' ) );
605 - });
606 -
607 - // Event handler: Show/hide Bypass Usernames based on Disable WordPress Logins checkbox.
608 - $( 'input[name="auth_settings[advanced_disable_wp_login]"]' ).on( 'change', function() {
609 589 var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
610 - animateOption( action, auth_settings_advanced_disable_wp_login_bypass_usernames );
590 + animateOption( action, auth_settings_external_ldap_host );
591 + animateOption( action, auth_settings_external_ldap_port );
592 + animateOption( action, auth_settings_external_ldap_search_base );
593 + animateOption( action, auth_settings_external_ldap_search_filter );
594 + animateOption( action, auth_settings_external_ldap_uid );
595 + animateOption( action, auth_settings_external_ldap_attr_email );
596 + animateOption( action, auth_settings_external_ldap_user );
597 + animateOption( action, auth_settings_external_ldap_password );
598 + animateOption( action, auth_settings_external_ldap_tls );
599 + animateOption( action, auth_settings_external_ldap_lostpassword_url );
600 + animateOption( action, auth_settings_external_ldap_attr_first_name );
601 + animateOption( action, auth_settings_external_ldap_attr_last_name );
602 + animateOption( action, auth_settings_external_ldap_attr_update_on_login );
603 + animateOption( action, auth_settings_external_ldap_test_user );
611 604 });
612 605
613 606 // Event handler: Test LDAP settings.
614 607 $( '#ldap_test_user_submit' ).on( 'click', function( event ) {
@@ -675,18 +668,12 @@
675 668 if ( ! $( '#auth_dashboard_widget' ).length ) {
676 669 var tab = '';
677 670 if ( getQuerystringValuesByKey( 'tab' ).length > 0 ) {
678 671 tab = getQuerystringValuesByKey( 'tab' )[0];
679 - // Remove querystring param (to avoid returning to that tab after saving
680 - // settings, where the user could have moved to a different tab which
681 - // would update the value in sessionStorage).
682 - url = new URL( window.location.href );
683 - url.searchParams.delete( 'tab' );
684 - window.history.replaceState( null, '', url.toString() );
685 672 } else if ( sessionStorage.getItem( 'tab' ) ) {
686 673 tab = sessionStorage.getItem( 'tab' );
687 674 }
688 - if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'external_oauth2', 'external_oidc', 'external_google', 'external_cas', 'external_ldap', 'advanced' ] ) < 0 ) {
675 + if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'advanced' ] ) < 0 ) {
689 676 tab = 'access_lists';
690 677 }
691 678 window.chooseTab( tab, animationSpeed );
692 679 }
@@ -748,37 +735,9 @@
748 735 $( 'textarea#auth_settings_ldap_search_base' ).autogrow();
749 736 $( 'textarea#auth_settings_ldap_search_filter' ).autogrow();
750 737 $( 'textarea#auth_settings_oauth2_hosteddomain' ).autogrow();
751 738 $( 'textarea#auth_settings_google_hosteddomain' ).autogrow();
752 - $( 'textarea#auth_settings_advanced_disable_wp_login_bypass_usernames' ).autogrow();
753 739
754 - // Enable select2 new user email notification dropdown.
755 - $( 'select#auth_settings_access_users_receive_pending_emails' ).select2({
756 - ajax: {
757 - url: ajaxurl,
758 - dataType: 'json',
759 - method: 'POST',
760 - data: function ( params ) {
761 - return {
762 - action: 'auth_settings_search_users',
763 - nonce: $( '#nonce_save_auth_settings' ).val(),
764 - query: params.term,
765 - page: params.page || 1,
766 - };
767 - },
768 - delay: 250, // Delay in milliseconds after user stops typing before sending the request.
769 - },
770 - closeOnSelect: true, // Controls whether the dropdown is closed after a selection is made.
771 - maximumInputLength: 50, // Maximum number of characters that may be provided for a search term.
772 - minimumInputLength: 1, // Minimum number of characters required to start a search.
773 - placeholder: authL10n.select_users,
774 - templateSelection: function( data ) {
775 - // Show just the username (data.id); fall back to the full display: username (email).
776 - return data.id || data.text;
777 - },
778 - width: '100%',
779 - // minimumResultsForSearch: 10,
780 - });
781 740 });
782 741
783 742
784 743 /**
@@ -820,9 +779,9 @@
820 779 // Hide (with overlay) site options if overridden by a multisite option.
821 780 window.hideMultisiteOverriddenOptions = function() {
822 781 $( '.auth_multisite_override_overlay' ).each( function() {
823 782 // Option to hide is stored in the overlay's id with 'overlay-hide-' prefix.
824 - var optionContainerToHide = $( this ).closest( 'td' );
783 + var optionContainerToHide = $( this ).closest( 'tr' );
825 784 if ( optionContainerToHide.length > 0 ) {
826 785 $( this ).css({
827 786 'background-color': '#f1f1f1',
828 787 'z-index': 1,
@@ -827,9 +786,8 @@
827 786 'background-color': '#f1f1f1',
828 787 'z-index': 1,
829 788 opacity: 0.8,
830 789 position: 'absolute',
831 - top: optionContainerToHide.css('padding-top'),
832 790 width: '100%',
833 791 height: optionContainerToHide.height(),
834 792 });
835 793 $( this ).show();
@@ -1146,10 +1104,8 @@
1146 1104
1147 1105 params.access_default_role = $( '#auth_settings_access_default_role' ).val();
1148 1106
1149 1107 params.oauth2 = $( '#auth_settings_oauth2' ).is( ':checked' ) ? '1' : '';
1150 - params.oauth2_auto_login = $( '#auth_settings_oauth2_auto_login' ).val();
1151 - params.oauth2_num_servers = parseInt( $( '#auth_settings_oauth2_num_servers' ).val() );
1152 1108 params.oauth2_provider = $( '#auth_settings_oauth2_provider' ).val();
1153 1109 params.oauth2_custom_label = $( '#auth_settings_oauth2_custom_label' ).val();
1154 1110 params.oauth2_clientid = $( '#auth_settings_oauth2_clientid' ).val();
1155 1111 params.oauth2_clientsecret = $( '#auth_settings_oauth2_clientsecret' ).val();
@@ -1157,75 +1113,10 @@
1157 1113 params.oauth2_tenant_id = $( '#auth_settings_oauth2_tenant_id' ).val();
1158 1114 params.oauth2_url_authorize = $( '#auth_settings_oauth2_url_authorize' ).val();
1159 1115 params.oauth2_url_token = $( '#auth_settings_oauth2_url_token' ).val();
1160 1116 params.oauth2_url_resource = $( '#auth_settings_oauth2_url_resource' ).val();
1161 - params.oauth2_attr_username = $( '#auth_settings_oauth2_attr_username' ).val();
1162 - params.oauth2_attr_email = $( '#auth_settings_oauth2_attr_email' ).val();
1163 - params.oauth2_attr_first_name = $( '#auth_settings_oauth2_attr_first_name' ).val();
1164 - params.oauth2_attr_last_name = $( '#auth_settings_oauth2_attr_last_name' ).val();
1165 - params.oauth2_attr_update_on_login = $( '#auth_settings_oauth2_attr_update_on_login' ).val();
1166 - params.oauth2_link_on_username = $( '#auth_settings_oauth2_link_on_username' ).is( ':checked' ) ? '1' : '';
1167 - if ( params.oauth2_num_servers > 1 ) {
1168 - for ( var oauth2_num_server = 2; oauth2_num_server <= params.oauth2_num_servers && oauth2_num_server <= 20; oauth2_num_server++ ) {
1169 - params['oauth2_provider_' + oauth2_num_server] = $( '#auth_settings_oauth2_provider_' + oauth2_num_server ).val();
1170 - params['oauth2_custom_label_' + oauth2_num_server] = $( '#auth_settings_oauth2_custom_label_' + oauth2_num_server ).val();
1171 - params['oauth2_clientid_' + oauth2_num_server] = $( '#auth_settings_oauth2_clientid_' + oauth2_num_server ).val();
1172 - params['oauth2_clientsecret_' + oauth2_num_server] = $( '#auth_settings_oauth2_clientsecret_' + oauth2_num_server ).val();
1173 - params['oauth2_hosteddomain_' + oauth2_num_server] = $( '#auth_settings_oauth2_hosteddomain_' + oauth2_num_server ).val();
1174 - params['oauth2_tenant_id_' + oauth2_num_server] = $( '#auth_settings_oauth2_tenant_id_' + oauth2_num_server ).val();
1175 - params['oauth2_url_authorize_' + oauth2_num_server] = $( '#auth_settings_oauth2_url_authorize_' + oauth2_num_server ).val();
1176 - params['oauth2_url_token_' + oauth2_num_server] = $( '#auth_settings_oauth2_url_token_' + oauth2_num_server ).val();
1177 - params['oauth2_url_resource_' + oauth2_num_server] = $( '#auth_settings_oauth2_url_resource_' + oauth2_num_server ).val();
1178 - params['oauth2_attr_username_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_username_' + oauth2_num_server ).val();
1179 - params['oauth2_attr_email_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_email_' + oauth2_num_server ).val();
1180 - params['oauth2_attr_first_name_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_first_name_' + oauth2_num_server ).val();
1181 - params['oauth2_attr_last_name_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_last_name_' + oauth2_num_server ).val();
1182 - params['oauth2_attr_update_on_login_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_update_on_login_' + oauth2_num_server ).val();
1183 - params['oauth2_link_on_username_' + oauth2_num_server] = $( '#auth_settings_oauth2_link_on_username_' + oauth2_num_server ).is( ':checked' ) ? '1' : '';
1184 - }
1185 - }
1117 + params.oauth2_auto_login = $( '#auth_settings_oauth2_auto_login' ).is( ':checked' ) ? '1' : '';
1186 1118
1187 - params.oidc = $( '#auth_settings_oidc' ).is( ':checked' ) ? '1' : '';
1188 - params.oidc_auto_login = $( '#auth_settings_oidc_auto_login' ).val();
1189 - params.oidc_num_servers = parseInt( $( '#auth_settings_oidc_num_servers' ).val() );
1190 - params.oidc_custom_label = $( '#auth_settings_oidc_custom_label' ).val();
1191 - params.oidc_issuer = $( '#auth_settings_oidc_issuer' ).val();
1192 - params.oidc_client_id = $( '#auth_settings_oidc_client_id' ).val();
1193 - params.oidc_client_secret = $( '#auth_settings_oidc_client_secret' ).val();
1194 - params.oidc_scopes = $( '#auth_settings_oidc_scopes' ).val();
1195 - params.oidc_prompt = $( '#auth_settings_oidc_prompt' ).val();
1196 - params.oidc_login_hint = $( '#auth_settings_oidc_login_hint' ).val();
1197 - params.oidc_max_age = $( '#auth_settings_oidc_max_age' ).val();
1198 - params.oidc_attr_username = $( '#auth_settings_oidc_attr_username' ).val();
1199 - params.oidc_attr_email = $( '#auth_settings_oidc_attr_email' ).val();
1200 - params.oidc_attr_first_name = $( '#auth_settings_oidc_attr_first_name' ).val();
1201 - params.oidc_attr_last_name = $( '#auth_settings_oidc_attr_last_name' ).val();
1202 - params.oidc_attr_update_on_login = $( '#auth_settings_oidc_attr_update_on_login' ).val();
1203 - params.oidc_force_auth_method = $( '#auth_settings_oidc_force_auth_method' ).val();
1204 - params.oidc_require_verified_email = $( '#auth_settings_oidc_require_verified_email' ).is( ':checked' ) ? '1' : '';
1205 - params.oidc_link_on_username = $( '#auth_settings_oidc_link_on_username' ).is( ':checked' ) ? '1' : '';
1206 - params.oidc_hosteddomain = $( '#auth_settings_oidc_hosteddomain' ).val();
1207 - if ( params.oidc_num_servers > 1 ) {
1208 - for ( var oidc_num_server = 2; oidc_num_server <= params.oidc_num_servers && oidc_num_server <= 20; oidc_num_server++ ) {
1209 - params['oidc_custom_label_' + oidc_num_server] = $( '#auth_settings_oidc_custom_label_' + oidc_num_server ).val();
1210 - params['oidc_issuer_' + oidc_num_server] = $( '#auth_settings_oidc_issuer_' + oidc_num_server ).val();
1211 - params['oidc_client_id_' + oidc_num_server] = $( '#auth_settings_oidc_client_id_' + oidc_num_server ).val();
1212 - params['oidc_client_secret_' + oidc_num_server] = $( '#auth_settings_oidc_client_secret_' + oidc_num_server ).val();
1213 - params['oidc_scopes_' + oidc_num_server] = $( '#auth_settings_oidc_scopes_' + oidc_num_server ).val();
1214 - params['oidc_prompt_' + oidc_num_server] = $( '#auth_settings_oidc_prompt_' + oidc_num_server ).val();
1215 - params['oidc_login_hint_' + oidc_num_server] = $( '#auth_settings_oidc_login_hint_' + oidc_num_server ).val();
1216 - params['oidc_max_age_' + oidc_num_server] = $( '#auth_settings_oidc_max_age_' + oidc_num_server ).val();
1217 - params['oidc_attr_username_' + oidc_num_server] = $( '#auth_settings_oidc_attr_username_' + oidc_num_server ).val();
1218 - params['oidc_attr_email_' + oidc_num_server] = $( '#auth_settings_oidc_attr_email_' + oidc_num_server ).val();
1219 - params['oidc_attr_first_name_' + oidc_num_server] = $( '#auth_settings_oidc_attr_first_name_' + oidc_num_server ).val();
1220 - params['oidc_attr_last_name_' + oidc_num_server] = $( '#auth_settings_oidc_attr_last_name_' + oidc_num_server ).val();
1221 - params['oidc_attr_update_on_login_' + oidc_num_server] = $( '#auth_settings_oidc_attr_update_on_login_' + oidc_num_server ).val();
1222 - params['oidc_force_auth_method_' + oidc_num_server] = $( '#auth_settings_oidc_force_auth_method_' + oidc_num_server ).val();
1223 - params['oidc_require_verified_email_' + oidc_num_server] = $( '#auth_settings_oidc_require_verified_email_' + oidc_num_server ).is( ':checked' ) ? '1' : '';
1224 - params['oidc_link_on_username_' + oidc_num_server] = $( '#auth_settings_oidc_link_on_username_' + oidc_num_server ).is( ':checked' ) ? '1' : '';
1225 - }
1226 - }
1227 -
1228 1119 params.google = $( '#auth_settings_google' ).is( ':checked' ) ? '1' : '';
1229 1120 params.google_clientid = $( '#auth_settings_google_clientid' ).val();
1230 1121 params.google_clientsecret = $( '#auth_settings_google_clientsecret' ).val();
1231 1122 params.google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val();
@@ -1230,10 +1121,9 @@
1230 1121 params.google_clientsecret = $( '#auth_settings_google_clientsecret' ).val();
1231 1122 params.google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val();
1232 1123
1233 1124 params.cas = $( '#auth_settings_cas' ).is( ':checked' ) ? '1' : '';
1234 - params.cas_auto_login = $( '#auth_settings_cas_auto_login' ).val();
1235 - params.cas_num_servers = parseInt( $( '#auth_settings_cas_num_servers' ).val() );
1125 + params.cas_auto_login = $( '#auth_settings_cas_auto_login' ).is( ':checked' ) ? '1' : '';
1236 1126 params.cas_custom_label = $( '#auth_settings_cas_custom_label' ).val();
1237 1127 params.cas_host = $( '#auth_settings_cas_host' ).val();
1238 1128 params.cas_port = $( '#auth_settings_cas_port' ).val();
1239 1129 params.cas_path = $( '#auth_settings_cas_path' ).val();
@@ -1243,23 +1133,8 @@
1243 1133 params.cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).val();
1244 1134 params.cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).val();
1245 1135 params.cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).val();
1246 1136 params.cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).is( ':checked' ) ? '1' : '';
1247 - if ( params.cas_num_servers > 1 ) {
1248 - for ( var cas_num_server = 2; cas_num_server <= params.cas_num_servers && cas_num_server <= 10; cas_num_server++ ) {
1249 - params['cas_custom_label_' + cas_num_server] = $( '#auth_settings_cas_custom_label_' + cas_num_server ).val();
1250 - params['cas_host_' + cas_num_server] = $( '#auth_settings_cas_host_' + cas_num_server ).val();
1251 - params['cas_port_' + cas_num_server] = $( '#auth_settings_cas_port_' + cas_num_server ).val();
1252 - params['cas_path_' + cas_num_server] = $( '#auth_settings_cas_path_' + cas_num_server ).val();
1253 - params['cas_method_' + cas_num_server] = $( '#auth_settings_cas_method_' + cas_num_server ).val();
1254 - params['cas_version_' + cas_num_server] = $( '#auth_settings_cas_version_' + cas_num_server ).val();
1255 - params['cas_attr_email_' + cas_num_server] = $( '#auth_settings_cas_attr_email_' + cas_num_server ).val();
1256 - params['cas_attr_first_name_' + cas_num_server] = $( '#auth_settings_cas_attr_first_name_' + cas_num_server ).val();
1257 - params['cas_attr_last_name_' + cas_num_server] = $( '#auth_settings_cas_attr_last_name_' + cas_num_server ).val();
1258 - params['cas_attr_update_on_login_' + cas_num_server] = $( '#auth_settings_cas_attr_update_on_login_' + cas_num_server ).val();
1259 - params['cas_link_on_username_' + cas_num_server] = $( '#auth_settings_cas_link_on_username_' + cas_num_server ).is( ':checked' ) ? '1' : '';
1260 - }
1261 - }
1262 1137
1263 1138 params.ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : '';
1264 1139 params.ldap_host = $( '#auth_settings_ldap_host' ).val();
1265 1140 params.ldap_port = $( '#auth_settings_ldap_port' ).val();
@@ -1284,10 +1159,8 @@
1284 1159 reset_duration: $( '#auth_settings_advanced_lockouts_reset_duration' ).val(),
1285 1160 };
1286 1161 params.advanced_hide_wp_login = $( '#auth_settings_advanced_hide_wp_login' ).is( ':checked' ) ? '1' : '';
1287 1162 params.advanced_disable_wp_login = $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ? '1' : '';
1288 - params.advanced_disable_wp_login_bypass_usernames = $( '#auth_settings_advanced_disable_wp_login_bypass_usernames' ).val();
1289 - params.advanced_show_usernames = $( '#auth_settings_advanced_show_usernames' ).is( ':checked' ) ? '1' : '';
1290 1163 params.advanced_widget_enabled = $( '#auth_settings_advanced_widget_enabled' ).is( ':checked' ) ? '1' : '';
1291 1164 params.advanced_users_per_page = $( '#auth_settings_advanced_users_per_page' ).val();
1292 1165 params.advanced_users_sort_by = $( '#auth_settings_advanced_users_sort_by' ).val();
1293 1166 params.advanced_users_sort_order = $( '#auth_settings_advanced_users_sort_order' ).val();
@@ -1302,15 +1175,8 @@
1302 1175 $( caller ).removeAttr( 'disabled' );
1303 1176
1304 1177 // Disable wait cursor.
1305 1178 $( 'html' ).removeClass( 'busy' );
1306 -
1307 - // If the save was successful, and we have more than 1 CAS or OAuth2
1308 - // servers configured, reload the page to render the additional CAS/Oauth2
1309 - // server settings fields.
1310 - if ( succeeded && ( params.cas_num_servers > 1 || params.oauth2_num_servers > 1 ) ) {
1311 - location.reload();
1312 - }
1313 1179 }).fail( function() {
1314 1180 // Fail fires if the server doesn't respond
1315 1181 var succeeded = false;
1316 1182 var spinnerText = succeeded ? authL10n.saved + '.' : '<span class="attention">' + authL10n.failed + '.</span>';