PluginProbe
Authorizer / 3.3.2
Authorizer v3.3.2
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 +292 -323 3.14.33.3.2 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').
@@ -272,15 +272,15 @@
272 272
273 273 // Helper function to hide/show wordpress option
274 274 function animateOption( action, option ) {
275 275 if ( action === 'show' ) {
276 - option.fadeIn( animationSpeed );
276 + $( 'div.animated_wrapper', option ).slideDown( animationSpeed );
277 277 $( 'th, td', option ).removeClass( 'hide-animate hide-no-animate' );
278 278 } else if ( action === 'hide' ) {
279 - option.fadeOut( animationSpeed );
279 + $( 'div.animated_wrapper', option ).slideUp( animationSpeed );
280 280 $( 'td, th', option ).addClass( 'hide-animate' );
281 281 } else if ( action === 'hide_immediately' ) {
282 - option.hide();
282 + $( 'div.animated_wrapper', option ).hide();
283 283 $( 'td, th', option ).addClass( 'hide-no-animate' );
284 284 }
285 285 }
286 286
@@ -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,83 +382,31 @@
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' );
387 - 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 - } );
407 - // OAuth2 settings below are for any additional OAuth2 servers configured (up to 20).
408 - for ( var i = 2; i <= parseInt( $( '#auth_settings_oauth2_num_servers' ).val() ) && i <= 20; i++ ) {
409 - auth_settings_external_oauth2_servers.push( {
410 - provider: $( '#auth_settings_oauth2_provider_' + i ).closest( 'tr' ),
411 - custom_label: $( '#auth_settings_oauth2_custom_label_' + i ).closest( 'tr' ),
412 - clientid: $( '#auth_settings_oauth2_clientid_' + i ).closest( 'tr' ),
413 - clientsecret: $( '#auth_settings_oauth2_clientsecret_' + i ).closest( 'tr' ),
414 - hosteddomain: $( '#auth_settings_oauth2_hosteddomain_' + i ).closest( 'tr' ),
415 - tenant_id: $( '#auth_settings_oauth2_tenant_id_' + i ).closest( 'tr' ),
416 - url_authorize: $( '#auth_settings_oauth2_url_authorize_' + i ).closest( 'tr' ),
417 - url_token: $( '#auth_settings_oauth2_url_token_' + i ).closest( 'tr' ),
418 - url_resource: $( '#auth_settings_oauth2_url_resource_' + i ).closest( 'tr' ),
419 - attr_username: $( '#auth_settings_oauth2_attr_username_' + i ).closest( 'tr' ),
420 - attr_email: $( '#auth_settings_oauth2_attr_email_' + i ).closest( 'tr' ),
421 - attr_first_name: $( '#auth_settings_oauth2_attr_first_name_' + i ).closest( 'tr' ),
422 - attr_last_name: $( '#auth_settings_oauth2_attr_last_name_' + i ).closest( 'tr' ),
423 - attr_update_on_login: $( '#auth_settings_oauth2_attr_update_on_login_' + i ).closest( 'tr' ),
424 - } );
425 - }
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' );
426 395 var auth_settings_external_google_clientid = $( '#auth_settings_google_clientid' ).closest( 'tr' );
427 396 var auth_settings_external_google_clientsecret = $( '#auth_settings_google_clientsecret' ).closest( 'tr' );
428 397 var auth_settings_external_google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).closest( 'tr' );
398 + var auth_settings_external_cas_custom_label = $( '#auth_settings_cas_custom_label' ).closest( 'tr' );
399 + var auth_settings_external_cas_host = $( '#auth_settings_cas_host' ).closest( 'tr' );
400 + var auth_settings_external_cas_port = $( '#auth_settings_cas_port' ).closest( 'tr' );
401 + var auth_settings_external_cas_path = $( '#auth_settings_cas_path' ).closest( 'tr' );
402 + var auth_settings_external_cas_version = $( '#auth_settings_cas_version' ).closest( 'tr' );
403 + var auth_settings_external_cas_attr_email = $( '#auth_settings_cas_attr_email' ).closest( 'tr' );
404 + var auth_settings_external_cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).closest( 'tr' );
405 + var auth_settings_external_cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).closest( 'tr' );
406 + var auth_settings_external_cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).closest( 'tr' );
429 407 var auth_settings_external_cas_auto_login = $( '#auth_settings_cas_auto_login' ).closest( 'tr' );
430 - var auth_settings_external_cas_num_servers = $( '#auth_settings_cas_num_servers' ).closest( 'tr' );
431 - var auth_settings_external_cas_servers = [];
432 - // CAS settings below are for the first configured CAS server.
433 - auth_settings_external_cas_servers.push( {
434 - custom_label: $( '#auth_settings_cas_custom_label' ).closest( 'tr' ),
435 - host: $( '#auth_settings_cas_host' ).closest( 'tr' ),
436 - port: $( '#auth_settings_cas_port' ).closest( 'tr' ),
437 - path: $( '#auth_settings_cas_path' ).closest( 'tr' ),
438 - method: $( '#auth_settings_cas_method' ).closest( 'tr' ),
439 - version: $( '#auth_settings_cas_version' ).closest( 'tr' ),
440 - attr_email: $( '#auth_settings_cas_attr_email' ).closest( 'tr' ),
441 - attr_first_name: $( '#auth_settings_cas_attr_first_name' ).closest( 'tr' ),
442 - attr_last_name: $( '#auth_settings_cas_attr_last_name' ).closest( 'tr' ),
443 - attr_update_on_login: $( '#auth_settings_cas_attr_update_on_login' ).closest( 'tr' ),
444 - link_on_username: $( '#auth_settings_cas_link_on_username' ).closest( 'tr' ),
445 - } );
446 - // CAS settings below are for any additional CAS servers configured (up to 10).
447 - for ( var i = 2; i <= parseInt( $( '#auth_settings_cas_num_servers' ).val() ) && i <= 10; i++ ) {
448 - auth_settings_external_cas_servers.push( {
449 - custom_label: $( '#auth_settings_cas_custom_label_' + i ).closest( 'tr' ),
450 - host: $( '#auth_settings_cas_host_' + i ).closest( 'tr' ),
451 - port: $( '#auth_settings_cas_port_' + i ).closest( 'tr' ),
452 - path: $( '#auth_settings_cas_path_' + i ).closest( 'tr' ),
453 - method: $( '#auth_settings_cas_method_' + i ).closest( 'tr' ),
454 - version: $( '#auth_settings_cas_version_' + i ).closest( 'tr' ),
455 - attr_email: $( '#auth_settings_cas_attr_email_' + i ).closest( 'tr' ),
456 - attr_first_name: $( '#auth_settings_cas_attr_first_name_' + i ).closest( 'tr' ),
457 - attr_last_name: $( '#auth_settings_cas_attr_last_name_' + i ).closest( 'tr' ),
458 - attr_update_on_login: $( '#auth_settings_cas_attr_update_on_login_' + i ).closest( 'tr' ),
459 - link_on_username: $( '#auth_settings_cas_link_on_username_' + i ).closest( 'tr' ),
460 - } );
461 - }
408 + var auth_settings_external_cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).closest( 'tr' );
462 409 var auth_settings_external_ldap_host = $( '#auth_settings_ldap_host' ).closest( 'tr' );
463 410 var auth_settings_external_ldap_port = $( '#auth_settings_ldap_port' ).closest( 'tr' );
464 411 var auth_settings_external_ldap_search_base = $( '#auth_settings_ldap_search_base' ).closest( 'tr' );
465 412 var auth_settings_external_ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).closest( 'tr' );
@@ -472,15 +419,62 @@
472 419 var auth_settings_external_ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).closest( 'tr' );
473 420 var auth_settings_external_ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).closest( 'tr' );
474 421 var auth_settings_external_ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).closest( 'tr' );
475 422 var auth_settings_external_ldap_test_user = $( '#auth_settings_ldap_test_user' ).closest( 'tr' );
476 - var auth_settings_advanced_disable_wp_login_bypass_usernames = $( '#auth_settings_advanced_disable_wp_login_bypass_usernames' ).closest( 'tr' );
477 423 /* eslint-enable */
478 424
425 + // Wrap the th and td in the rows above so we can animate their heights (can't animate tr heights with jquery)
426 + $( 'th, td', auth_settings_access_role_receive_pending_emails ).wrapInner( '<div class="animated_wrapper" />' );
427 + $( 'th, td', auth_settings_access_pending_redirect_to_message ).wrapInner( '<div class="animated_wrapper" />' );
428 + $( 'th, td', auth_settings_access_blocked_redirect_to_message ).wrapInner( '<div class="animated_wrapper" />' );
429 + $( 'th, td', auth_settings_access_should_email_approved_users ).wrapInner( '<div class="animated_wrapper" />' );
430 + $( 'th, td', auth_settings_access_email_approved_users_subject ).wrapInner( '<div class="animated_wrapper" />' );
431 + $( 'th, td', auth_settings_access_email_approved_users_body ).wrapInner( '<div class="animated_wrapper" />' );
432 + $( 'th, td', auth_settings_access_public_pages ).wrapInner( '<div class="animated_wrapper" />' );
433 + $( 'th, td', auth_settings_access_redirect_to_login ).wrapInner( '<div class="animated_wrapper" />' );
434 + $( 'th, td', auth_settings_access_public_warning ).wrapInner( '<div class="animated_wrapper" />' );
435 + $( 'th, td', auth_settings_access_redirect_to_message ).wrapInner( '<div class="animated_wrapper" />' );
436 + $( 'th, td', auth_settings_external_oauth2_provider ).wrapInner( '<div class="animated_wrapper" />' );
437 + $( 'th, td', auth_settings_external_oauth2_custom_label ).wrapInner( '<div class="animated_wrapper" />' );
438 + $( 'th, td', auth_settings_external_oauth2_clientid ).wrapInner( '<div class="animated_wrapper" />' );
439 + $( 'th, td', auth_settings_external_oauth2_clientsecret ).wrapInner( '<div class="animated_wrapper" />' );
440 + $( 'th, td', auth_settings_external_oauth2_hosteddomain ).wrapInner( '<div class="animated_wrapper" />' );
441 + $( 'th, td', auth_settings_external_oauth2_tenant_id ).wrapInner( '<div class="animated_wrapper" />' );
442 + $( 'th, td', auth_settings_external_oauth2_url_authorize ).wrapInner( '<div class="animated_wrapper" />' );
443 + $( 'th, td', auth_settings_external_oauth2_url_token ).wrapInner( '<div class="animated_wrapper" />' );
444 + $( 'th, td', auth_settings_external_oauth2_url_resource ).wrapInner( '<div class="animated_wrapper" />' );
445 + $( 'th, td', auth_settings_external_google_clientid ).wrapInner( '<div class="animated_wrapper" />' );
446 + $( 'th, td', auth_settings_external_google_clientsecret ).wrapInner( '<div class="animated_wrapper" />' );
447 + $( 'th, td', auth_settings_external_google_hosteddomain ).wrapInner( '<div class="animated_wrapper" />' );
448 + $( 'th, td', auth_settings_external_cas_custom_label ).wrapInner( '<div class="animated_wrapper" />' );
449 + $( 'th, td', auth_settings_external_cas_host ).wrapInner( '<div class="animated_wrapper" />' );
450 + $( 'th, td', auth_settings_external_cas_port ).wrapInner( '<div class="animated_wrapper" />' );
451 + $( 'th, td', auth_settings_external_cas_path ).wrapInner( '<div class="animated_wrapper" />' );
452 + $( 'th, td', auth_settings_external_cas_version ).wrapInner( '<div class="animated_wrapper" />' );
453 + $( 'th, td', auth_settings_external_cas_attr_email ).wrapInner( '<div class="animated_wrapper" />' );
454 + $( 'th, td', auth_settings_external_cas_attr_first_name ).wrapInner( '<div class="animated_wrapper" />' );
455 + $( 'th, td', auth_settings_external_cas_attr_last_name ).wrapInner( '<div class="animated_wrapper" />' );
456 + $( 'th, td', auth_settings_external_cas_attr_update_on_login ).wrapInner( '<div class="animated_wrapper" />' );
457 + $( 'th, td', auth_settings_external_cas_auto_login ).wrapInner( '<div class="animated_wrapper" />' );
458 + $( 'th, td', auth_settings_external_cas_link_on_username ).wrapInner( '<div class="animated_wrapper" />' );
459 + $( 'th, td', auth_settings_external_ldap_host ).wrapInner( '<div class="animated_wrapper" />' );
460 + $( 'th, td', auth_settings_external_ldap_port ).wrapInner( '<div class="animated_wrapper" />' );
461 + $( 'th, td', auth_settings_external_ldap_search_base ).wrapInner( '<div class="animated_wrapper" />' );
462 + $( 'th, td', auth_settings_external_ldap_search_filter ).wrapInner( '<div class="animated_wrapper" />' );
463 + $( 'th, td', auth_settings_external_ldap_uid ).wrapInner( '<div class="animated_wrapper" />' );
464 + $( 'th, td', auth_settings_external_ldap_attr_email ).wrapInner( '<div class="animated_wrapper" />' );
465 + $( 'th, td', auth_settings_external_ldap_user ).wrapInner( '<div class="animated_wrapper" />' );
466 + $( 'th, td', auth_settings_external_ldap_password ).wrapInner( '<div class="animated_wrapper" />' );
467 + $( 'th, td', auth_settings_external_ldap_tls ).wrapInner( '<div class="animated_wrapper" />' );
468 + $( 'th, td', auth_settings_external_ldap_lostpassword_url ).wrapInner( '<div class="animated_wrapper" />' );
469 + $( 'th, td', auth_settings_external_ldap_attr_first_name ).wrapInner( '<div class="animated_wrapper" />' );
470 + $( 'th, td', auth_settings_external_ldap_attr_last_name ).wrapInner( '<div class="animated_wrapper" />' );
471 + $( 'th, td', auth_settings_external_ldap_attr_update_on_login ).wrapInner( '<div class="animated_wrapper" />' );
472 + $( 'th, td', auth_settings_external_ldap_test_user ).wrapInner( '<div class="animated_wrapper" />' );
473 +
479 474 // Hide settings unless "Only approved users" is checked
480 475 if ( ! $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ) {
481 476 animateOption( 'hide_immediately', auth_settings_access_role_receive_pending_emails );
482 - animateOption( 'hide_immediately', auth_settings_access_users_receive_pending_emails );
483 477 animateOption( 'hide_immediately', auth_settings_access_pending_redirect_to_message );
484 478 animateOption( 'hide_immediately', auth_settings_access_blocked_redirect_to_message );
485 479 animateOption( 'hide_immediately', auth_settings_access_should_email_approved_users );
486 480 }
@@ -498,45 +492,74 @@
498 492 animateOption( 'hide_immediately', auth_settings_access_public_warning );
499 493 animateOption( 'hide_immediately', auth_settings_access_redirect_to_message );
500 494 }
501 495
502 - // Hide External Service tabs if provider is unchecked.
503 - $( '.nav-tab-wrapper .nav-tab-external_oauth2' ).toggle( $( '#auth_settings_oauth2' ).is( ':checked' ) );
504 - $( '.nav-tab-wrapper .nav-tab-external_oidc' ).toggle( $( '#auth_settings_oidc' ).is( ':checked' ) );
505 - $( '.nav-tab-wrapper .nav-tab-external_google' ).toggle( $( '#auth_settings_google' ).is( ':checked' ) );
506 - $( '.nav-tab-wrapper .nav-tab-external_cas' ).toggle( $( '#auth_settings_cas' ).is( ':checked' ) );
507 - $( '.nav-tab-wrapper .nav-tab-external_ldap' ).toggle( $( '#auth_settings_ldap' ).is( ':checked' ) );
496 + // Hide OAuth2 options if unchecked.
497 + if ( ! $( '#auth_settings_oauth2' ).is( ':checked' ) ) {
498 + animateOption( 'hide_immediately', auth_settings_external_oauth2_provider );
499 + animateOption( 'hide_immediately', auth_settings_external_oauth2_custom_label );
500 + animateOption( 'hide_immediately', auth_settings_external_oauth2_clientid );
501 + animateOption( 'hide_immediately', auth_settings_external_oauth2_clientsecret );
502 + animateOption( 'hide_immediately', auth_settings_external_oauth2_hosteddomain );
503 + }
508 504
509 - // Hide some OAuth2 options based on current settings.
510 - auth_settings_external_oauth2_servers.forEach( function( server ) {
511 - // Hide OAuth2 generic options if OAuth2 provider is unchecked or generic isn't chosen.
512 - if ( 'generic' !== server.provider.find( 'select' ).val() ) {
513 - animateOption( 'hide_immediately', server.url_authorize );
514 - animateOption( 'hide_immediately', server.url_token );
515 - animateOption( 'hide_immediately', server.url_resource );
516 - animateOption( 'hide_immediately', server.attr_username );
517 - animateOption( 'hide_immediately', server.attr_email );
518 - animateOption( 'hide_immediately', server.attr_first_name );
519 - animateOption( 'hide_immediately', server.attr_last_name );
520 - animateOption( 'hide_immediately', server.attr_update_on_login );
521 - }
522 - // Hide OAuth2 Tenant ID if OAuth2 provider is unchecked or azure isn't chosen.
523 - if ( 'azure' !== server.provider.find( 'select' ).val() ) {
524 - animateOption( 'hide_immediately', server.tenant_id );
525 - }
526 - } );
505 + // Hide OAuth2 generic options if generic isn't chosen.
506 + if ( ! $( '#auth_settings_oauth2' ).is( ':checked' ) || 'generic' !== $( '#auth_settings_oauth2_provider' ).val() ) {
507 + animateOption( 'hide_immediately', auth_settings_external_oauth2_url_authorize );
508 + animateOption( 'hide_immediately', auth_settings_external_oauth2_url_token );
509 + animateOption( 'hide_immediately', auth_settings_external_oauth2_url_resource );
510 + }
527 511
528 - // Hide Bypass Usernames if Disable WordPress logins is unchecked.
529 - if ( ! $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ) {
530 - animateOption( 'hide_immediately', auth_settings_advanced_disable_wp_login_bypass_usernames );
512 + // Hide OAuth2 Tenant ID if azure isn't chosen.
513 + if ( ! $( '#auth_settings_oauth2' ).is( ':checked' ) || 'azure' !== $( '#auth_settings_oauth2_provider' ).val() ) {
514 + animateOption( 'hide_immediately', auth_settings_external_oauth2_tenant_id );
531 515 }
532 516
517 + // Hide Google options if unchecked
518 + if ( ! $( '#auth_settings_google' ).is( ':checked' ) ) {
519 + animateOption( 'hide_immediately', auth_settings_external_google_clientid );
520 + animateOption( 'hide_immediately', auth_settings_external_google_clientsecret );
521 + animateOption( 'hide_immediately', auth_settings_external_google_hosteddomain );
522 + }
523 +
524 + // Hide CAS options if unchecked
525 + if ( ! $( '#auth_settings_cas' ).is( ':checked' ) ) {
526 + animateOption( 'hide_immediately', auth_settings_external_cas_custom_label );
527 + animateOption( 'hide_immediately', auth_settings_external_cas_host );
528 + animateOption( 'hide_immediately', auth_settings_external_cas_port );
529 + animateOption( 'hide_immediately', auth_settings_external_cas_path );
530 + animateOption( 'hide_immediately', auth_settings_external_cas_version );
531 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_email );
532 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_first_name );
533 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_last_name );
534 + animateOption( 'hide_immediately', auth_settings_external_cas_attr_update_on_login );
535 + animateOption( 'hide_immediately', auth_settings_external_cas_auto_login );
536 + animateOption( 'hide_immediately', auth_settings_external_cas_link_on_username );
537 + }
538 +
539 + // Hide LDAP options if unchecked
540 + if ( ! $( '#auth_settings_ldap' ).is( ':checked' ) ) {
541 + animateOption( 'hide_immediately', auth_settings_external_ldap_host );
542 + animateOption( 'hide_immediately', auth_settings_external_ldap_port );
543 + animateOption( 'hide_immediately', auth_settings_external_ldap_search_base );
544 + animateOption( 'hide_immediately', auth_settings_external_ldap_search_filter );
545 + animateOption( 'hide_immediately', auth_settings_external_ldap_uid );
546 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_email );
547 + animateOption( 'hide_immediately', auth_settings_external_ldap_user );
548 + animateOption( 'hide_immediately', auth_settings_external_ldap_password );
549 + animateOption( 'hide_immediately', auth_settings_external_ldap_tls );
550 + animateOption( 'hide_immediately', auth_settings_external_ldap_lostpassword_url );
551 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_first_name );
552 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_last_name );
553 + animateOption( 'hide_immediately', auth_settings_external_ldap_attr_update_on_login );
554 + animateOption( 'hide_immediately', auth_settings_external_ldap_test_user );
555 + }
556 +
533 557 // Event handler: Hide "Handle unauthorized visitors" option if access is granted to "Everyone"
534 558 $( 'input[name="auth_settings[access_who_can_login]"]' ).on( 'change', function() {
535 559 // Hide settings unless "Only approved users" is checked
536 560 var action = $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ? 'show' : 'hide';
537 561 animateOption( action, auth_settings_access_role_receive_pending_emails );
538 - animateOption( action, auth_settings_access_users_receive_pending_emails );
539 562 animateOption( action, auth_settings_access_pending_redirect_to_message );
540 563 animateOption( action, auth_settings_access_blocked_redirect_to_message );
541 564 animateOption( action, auth_settings_access_should_email_approved_users );
542 565 action = action === 'show' && $( '#auth_settings_access_should_email_approved_users' ).is( ':checked' ) ? 'show' : 'hide_immediately';
@@ -559,54 +582,69 @@
559 582 animateOption( action, auth_settings_access_public_pages );
560 583 animateOption( action, auth_settings_access_public_warning );
561 584 });
562 585
563 - // Event handler: Show/hide OAuth2 tab based on checkbox.
586 + // Event handler: Show/hide OAuth2 options based on checkbox.
564 587 $( 'input[name="auth_settings[oauth2]"]' ).on( 'change', function() {
565 - $( '.nav-tab-wrapper .nav-tab-external_oauth2' ).toggle( $( this ).is( ':checked' ) );
588 + var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
589 + animateOption( action, auth_settings_external_oauth2_provider );
590 + animateOption( action, auth_settings_external_oauth2_custom_label );
591 + animateOption( action, auth_settings_external_oauth2_clientid );
592 + animateOption( action, auth_settings_external_oauth2_clientsecret );
593 + animateOption( action, auth_settings_external_oauth2_hosteddomain );
566 594 });
567 595
568 - // Event handler: Show/hide OAuth2 generic/azure options based on provider.
569 - auth_settings_external_oauth2_servers.forEach( function( server ) {
570 - server.provider.find( 'select' ).on( 'change', function() {
571 - var action = 'generic' === $( this ).val() ? 'show' : 'hide';
572 - animateOption( action, server.url_authorize );
573 - animateOption( action, server.url_token );
574 - animateOption( action, server.url_resource );
575 - animateOption( action, server.attr_username );
576 - animateOption( action, server.attr_email );
577 - animateOption( action, server.attr_first_name );
578 - animateOption( action, server.attr_last_name );
579 - animateOption( action, server.attr_update_on_login );
580 - action = 'azure' === $( this ).val() ? 'show' : 'hide';
581 - animateOption( action, server.tenant_id );
582 - });
596 + // Event handler: Show/hide OAuth2 generic options based on provider.
597 + $( 'select[name="auth_settings[oauth2_provider]"]' ).on( 'change', function() {
598 + var action = 'generic' === $( this ).val() ? 'show' : 'hide';
599 + animateOption( action, auth_settings_external_oauth2_url_authorize );
600 + animateOption( action, auth_settings_external_oauth2_url_token );
601 + animateOption( action, auth_settings_external_oauth2_url_resource );
602 + action = 'azure' === $( this ).val() ? 'show' : 'hide';
603 + animateOption( action, auth_settings_external_oauth2_tenant_id );
583 604 });
584 605
585 - // Event handler: Show/hide OIDC tab based on checkbox
586 - $( 'input[name="auth_settings[oidc]"]' ).on( 'change', function() {
587 - $( '.nav-tab-wrapper .nav-tab-external_oidc' ).toggle( $( this ).is( ':checked' ) );
588 - });
589 -
590 - // Event handler: Show/hide Google tab based on checkbox
606 + // Event handler: Show/hide Google options based on checkbox
591 607 $( 'input[name="auth_settings[google]"]' ).on( 'change', function() {
592 - $( '.nav-tab-wrapper .nav-tab-external_google' ).toggle( $( this ).is( ':checked' ) );
608 + var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
609 + animateOption( action, auth_settings_external_google_clientid );
610 + animateOption( action, auth_settings_external_google_clientsecret );
611 + animateOption( action, auth_settings_external_google_hosteddomain );
593 612 });
594 613
595 - // Event handler: Show/hide CAS tab based on checkbox
614 + // Event handler: Show/hide CAS options based on checkbox
596 615 $( 'input[name="auth_settings[cas]"]' ).on( 'change', function() {
597 - $( '.nav-tab-wrapper .nav-tab-external_cas' ).toggle( $( this ).is( ':checked' ) );
616 + var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
617 + animateOption( action, auth_settings_external_cas_custom_label );
618 + animateOption( action, auth_settings_external_cas_host );
619 + animateOption( action, auth_settings_external_cas_port );
620 + animateOption( action, auth_settings_external_cas_path );
621 + animateOption( action, auth_settings_external_cas_version );
622 + animateOption( action, auth_settings_external_cas_attr_email );
623 + animateOption( action, auth_settings_external_cas_attr_first_name );
624 + animateOption( action, auth_settings_external_cas_attr_last_name );
625 + animateOption( action, auth_settings_external_cas_attr_update_on_login );
626 + animateOption( action, auth_settings_external_cas_auto_login );
627 + animateOption( action, auth_settings_external_cas_link_on_username );
598 628 });
599 629
600 - // Event handler: Show/hide LDAP tab based on checkbox
630 + // Event handler: Show/hide LDAP options based on checkbox
601 631 $( 'input[name="auth_settings[ldap]"]' ).on( 'change', function() {
602 - $( '.nav-tab-wrapper .nav-tab-external_ldap' ).toggle( $( this ).is( ':checked' ) );
603 - });
604 -
605 - // Event handler: Show/hide Bypass Usernames based on Disable WordPress Logins checkbox.
606 - $( 'input[name="auth_settings[advanced_disable_wp_login]"]' ).on( 'change', function() {
607 632 var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
608 - animateOption( action, auth_settings_advanced_disable_wp_login_bypass_usernames );
633 + animateOption( action, auth_settings_external_ldap_host );
634 + animateOption( action, auth_settings_external_ldap_port );
635 + animateOption( action, auth_settings_external_ldap_search_base );
636 + animateOption( action, auth_settings_external_ldap_search_filter );
637 + animateOption( action, auth_settings_external_ldap_uid );
638 + animateOption( action, auth_settings_external_ldap_attr_email );
639 + animateOption( action, auth_settings_external_ldap_user );
640 + animateOption( action, auth_settings_external_ldap_password );
641 + animateOption( action, auth_settings_external_ldap_tls );
642 + animateOption( action, auth_settings_external_ldap_lostpassword_url );
643 + animateOption( action, auth_settings_external_ldap_attr_first_name );
644 + animateOption( action, auth_settings_external_ldap_attr_last_name );
645 + animateOption( action, auth_settings_external_ldap_attr_update_on_login );
646 + animateOption( action, auth_settings_external_ldap_test_user );
609 647 });
610 648
611 649 // Event handler: Test LDAP settings.
612 650 $( '#ldap_test_user_submit' ).on( 'click', function( event ) {
@@ -676,9 +714,9 @@
676 714 tab = getQuerystringValuesByKey( 'tab' )[0];
677 715 } else if ( sessionStorage.getItem( 'tab' ) ) {
678 716 tab = sessionStorage.getItem( 'tab' );
679 717 }
680 - if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'external_oauth2', 'external_oidc', 'external_google', 'external_cas', 'external_ldap', 'advanced' ] ) < 0 ) {
718 + if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'advanced' ] ) < 0 ) {
681 719 tab = 'access_lists';
682 720 }
683 721 window.chooseTab( tab, animationSpeed );
684 722 }
@@ -740,37 +778,9 @@
740 778 $( 'textarea#auth_settings_ldap_search_base' ).autogrow();
741 779 $( 'textarea#auth_settings_ldap_search_filter' ).autogrow();
742 780 $( 'textarea#auth_settings_oauth2_hosteddomain' ).autogrow();
743 781 $( 'textarea#auth_settings_google_hosteddomain' ).autogrow();
744 - $( 'textarea#auth_settings_advanced_disable_wp_login_bypass_usernames' ).autogrow();
745 782
746 - // Enable select2 new user email notification dropdown.
747 - $( 'select#auth_settings_access_users_receive_pending_emails' ).select2({
748 - ajax: {
749 - url: ajaxurl,
750 - dataType: 'json',
751 - method: 'POST',
752 - data: function ( params ) {
753 - return {
754 - action: 'auth_settings_search_users',
755 - nonce: $( '#nonce_save_auth_settings' ).val(),
756 - query: params.term,
757 - page: params.page || 1,
758 - };
759 - },
760 - delay: 250, // Delay in milliseconds after user stops typing before sending the request.
761 - },
762 - closeOnSelect: true, // Controls whether the dropdown is closed after a selection is made.
763 - maximumInputLength: 50, // Maximum number of characters that may be provided for a search term.
764 - minimumInputLength: 1, // Minimum number of characters required to start a search.
765 - placeholder: authL10n.select_users,
766 - templateSelection: function( data ) {
767 - // Show just the username (data.id); fall back to the full display: username (email).
768 - return data.id || data.text;
769 - },
770 - width: '100%',
771 - // minimumResultsForSearch: 10,
772 - });
773 783 });
774 784
775 785
776 786 /**
@@ -812,9 +822,9 @@
812 822 // Hide (with overlay) site options if overridden by a multisite option.
813 823 window.hideMultisiteOverriddenOptions = function() {
814 824 $( '.auth_multisite_override_overlay' ).each( function() {
815 825 // Option to hide is stored in the overlay's id with 'overlay-hide-' prefix.
816 - var optionContainerToHide = $( this ).closest( 'td' );
826 + var optionContainerToHide = $( this ).closest( 'tr' );
817 827 if ( optionContainerToHide.length > 0 ) {
818 828 $( this ).css({
819 829 'background-color': '#f1f1f1',
820 830 'z-index': 1,
@@ -819,9 +829,8 @@
819 829 'background-color': '#f1f1f1',
820 830 'z-index': 1,
821 831 opacity: 0.8,
822 832 position: 'absolute',
823 - top: optionContainerToHide.css('padding-top'),
824 833 width: '100%',
825 834 height: optionContainerToHide.height(),
826 835 });
827 836 $( this ).show();
@@ -1111,23 +1120,18 @@
1111 1120 left: $( caller ).position().left + $( caller ).width() + 20,
1112 1121 });
1113 1122 $( caller ).after( $spinner );
1114 1123
1115 - // Get form elements to save.
1116 - var params = {
1117 - action: 'save_auth_multisite_settings',
1118 - nonce: $( '#nonce_save_auth_settings' ).val(),
1119 - };
1124 + // Get form elements to save
1125 + var nonce_save_auth_settings = $( '#nonce_save_auth_settings' ).val();
1120 1126
1121 - params.multisite_override = $( '#auth_settings_multisite_override' ).is( ':checked' ) ? '1' : '';
1127 + var multisite_override = $( '#auth_settings_multisite_override' ).is( ':checked' ) ? '1' : '';
1122 1128
1123 - params.prevent_override_multisite = $( '#auth_settings_prevent_override_multisite' ).is( ':checked' ) ? '1' : '';
1129 + var access_who_can_login = $( 'form input[name="auth_settings[access_who_can_login]"]:checked' ).val();
1124 1130
1125 - params.access_who_can_login = $( 'form input[name="auth_settings[access_who_can_login]"]:checked' ).val();
1131 + var access_who_can_view = $( 'form input[name="auth_settings[access_who_can_view]"]:checked' ).val();
1126 1132
1127 - params.access_who_can_view = $( 'form input[name="auth_settings[access_who_can_view]"]:checked' ).val();
1128 -
1129 - params.access_users_approved = {};
1133 + var access_users_approved = {};
1130 1134 $( '#list_auth_settings_access_users_approved li' ).each( function( index ) {
1131 1135 var user = {};
1132 1136 user.email = $( '.auth-email', this ).val();
1133 1137 user.role = $( '.auth-role', this ).val();
@@ -1132,142 +1136,59 @@
1132 1136 user.email = $( '.auth-email', this ).val();
1133 1137 user.role = $( '.auth-role', this ).val();
1134 1138 user.date_added = $( '.auth-date-added', this ).val();
1135 1139 user.local_user = $( '.auth-local-user', this ).length !== 0;
1136 - params.access_users_approved[index] = user;
1140 + access_users_approved[index] = user;
1137 1141 });
1138 1142
1139 - params.access_default_role = $( '#auth_settings_access_default_role' ).val();
1143 + var access_default_role = $( '#auth_settings_access_default_role' ).val();
1140 1144
1141 - params.oauth2 = $( '#auth_settings_oauth2' ).is( ':checked' ) ? '1' : '';
1142 - params.oauth2_auto_login = $( '#auth_settings_oauth2_auto_login' ).val();
1143 - params.oauth2_num_servers = parseInt( $( '#auth_settings_oauth2_num_servers' ).val() );
1144 - params.oauth2_provider = $( '#auth_settings_oauth2_provider' ).val();
1145 - params.oauth2_custom_label = $( '#auth_settings_oauth2_custom_label' ).val();
1146 - params.oauth2_clientid = $( '#auth_settings_oauth2_clientid' ).val();
1147 - params.oauth2_clientsecret = $( '#auth_settings_oauth2_clientsecret' ).val();
1148 - params.oauth2_hosteddomain = $( '#auth_settings_oauth2_hosteddomain' ).val();
1149 - params.oauth2_tenant_id = $( '#auth_settings_oauth2_tenant_id' ).val();
1150 - params.oauth2_url_authorize = $( '#auth_settings_oauth2_url_authorize' ).val();
1151 - params.oauth2_url_token = $( '#auth_settings_oauth2_url_token' ).val();
1152 - params.oauth2_url_resource = $( '#auth_settings_oauth2_url_resource' ).val();
1153 - params.oauth2_attr_username = $( '#auth_settings_oauth2_attr_username' ).val();
1154 - params.oauth2_attr_email = $( '#auth_settings_oauth2_attr_email' ).val();
1155 - params.oauth2_attr_first_name = $( '#auth_settings_oauth2_attr_first_name' ).val();
1156 - params.oauth2_attr_last_name = $( '#auth_settings_oauth2_attr_last_name' ).val();
1157 - params.oauth2_attr_update_on_login = $( '#auth_settings_oauth2_attr_update_on_login' ).val();
1158 - if ( params.oauth2_num_servers > 1 ) {
1159 - for ( var oauth2_num_server = 2; oauth2_num_server <= params.oauth2_num_servers && oauth2_num_server <= 20; oauth2_num_server++ ) {
1160 - params['oauth2_provider_' + oauth2_num_server] = $( '#auth_settings_oauth2_provider_' + oauth2_num_server ).val();
1161 - params['oauth2_custom_label_' + oauth2_num_server] = $( '#auth_settings_oauth2_custom_label_' + oauth2_num_server ).val();
1162 - params['oauth2_clientid_' + oauth2_num_server] = $( '#auth_settings_oauth2_clientid_' + oauth2_num_server ).val();
1163 - params['oauth2_clientsecret_' + oauth2_num_server] = $( '#auth_settings_oauth2_clientsecret_' + oauth2_num_server ).val();
1164 - params['oauth2_hosteddomain_' + oauth2_num_server] = $( '#auth_settings_oauth2_hosteddomain_' + oauth2_num_server ).val();
1165 - params['oauth2_tenant_id_' + oauth2_num_server] = $( '#auth_settings_oauth2_tenant_id_' + oauth2_num_server ).val();
1166 - params['oauth2_url_authorize_' + oauth2_num_server] = $( '#auth_settings_oauth2_url_authorize_' + oauth2_num_server ).val();
1167 - params['oauth2_url_token_' + oauth2_num_server] = $( '#auth_settings_oauth2_url_token_' + oauth2_num_server ).val();
1168 - params['oauth2_url_resource_' + oauth2_num_server] = $( '#auth_settings_oauth2_url_resource_' + oauth2_num_server ).val();
1169 - params['oauth2_attr_username_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_username_' + oauth2_num_server ).val();
1170 - params['oauth2_attr_email_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_email_' + oauth2_num_server ).val();
1171 - params['oauth2_attr_first_name_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_first_name_' + oauth2_num_server ).val();
1172 - params['oauth2_attr_last_name_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_last_name_' + oauth2_num_server ).val();
1173 - params['oauth2_attr_update_on_login_' + oauth2_num_server] = $( '#auth_settings_oauth2_attr_update_on_login_' + oauth2_num_server ).val();
1174 - }
1175 - }
1145 + var oauth2 = $( '#auth_settings_oauth2' ).is( ':checked' ) ? '1' : '';
1146 + var oauth2_provider = $( '#auth_settings_oauth2_provider' ).val();
1147 + var oauth2_custom_label = $( '#auth_settings_oauth2_custom_label' ).val();
1148 + var oauth2_clientid = $( '#auth_settings_oauth2_clientid' ).val();
1149 + var oauth2_clientsecret = $( '#auth_settings_oauth2_clientsecret' ).val();
1150 + var oauth2_hosteddomain = $( '#auth_settings_oauth2_hosteddomain' ).val();
1151 + var oauth2_tenant_id = $( '#auth_settings_oauth2_tenant_id' ).val();
1152 + var oauth2_url_authorize = $( '#auth_settings_oauth2_url_authorize' ).val();
1153 + var oauth2_url_token = $( '#auth_settings_oauth2_url_token' ).val();
1154 + var oauth2_url_resource = $( '#auth_settings_oauth2_url_resource' ).val();
1176 1155
1177 - params.oidc = $( '#auth_settings_oidc' ).is( ':checked' ) ? '1' : '';
1178 - params.oidc_auto_login = $( '#auth_settings_oidc_auto_login' ).val();
1179 - params.oidc_num_servers = parseInt( $( '#auth_settings_oidc_num_servers' ).val() );
1180 - params.oidc_custom_label = $( '#auth_settings_oidc_custom_label' ).val();
1181 - params.oidc_issuer = $( '#auth_settings_oidc_issuer' ).val();
1182 - params.oidc_client_id = $( '#auth_settings_oidc_client_id' ).val();
1183 - params.oidc_client_secret = $( '#auth_settings_oidc_client_secret' ).val();
1184 - params.oidc_scopes = $( '#auth_settings_oidc_scopes' ).val();
1185 - params.oidc_prompt = $( '#auth_settings_oidc_prompt' ).val();
1186 - params.oidc_login_hint = $( '#auth_settings_oidc_login_hint' ).val();
1187 - params.oidc_max_age = $( '#auth_settings_oidc_max_age' ).val();
1188 - params.oidc_attr_username = $( '#auth_settings_oidc_attr_username' ).val();
1189 - params.oidc_attr_email = $( '#auth_settings_oidc_attr_email' ).val();
1190 - params.oidc_attr_first_name = $( '#auth_settings_oidc_attr_first_name' ).val();
1191 - params.oidc_attr_last_name = $( '#auth_settings_oidc_attr_last_name' ).val();
1192 - params.oidc_attr_update_on_login = $( '#auth_settings_oidc_attr_update_on_login' ).val();
1193 - params.oidc_force_auth_method = $( '#auth_settings_oidc_force_auth_method' ).val();
1194 - params.oidc_require_verified_email = $( '#auth_settings_oidc_require_verified_email' ).is( ':checked' ) ? '1' : '';
1195 - params.oidc_link_on_username = $( '#auth_settings_oidc_link_on_username' ).is( ':checked' ) ? '1' : '';
1196 - params.oidc_hosteddomain = $( '#auth_settings_oidc_hosteddomain' ).val();
1197 - if ( params.oidc_num_servers > 1 ) {
1198 - for ( var oidc_num_server = 2; oidc_num_server <= params.oidc_num_servers && oidc_num_server <= 20; oidc_num_server++ ) {
1199 - params['oidc_custom_label_' + oidc_num_server] = $( '#auth_settings_oidc_custom_label_' + oidc_num_server ).val();
1200 - params['oidc_issuer_' + oidc_num_server] = $( '#auth_settings_oidc_issuer_' + oidc_num_server ).val();
1201 - params['oidc_client_id_' + oidc_num_server] = $( '#auth_settings_oidc_client_id_' + oidc_num_server ).val();
1202 - params['oidc_client_secret_' + oidc_num_server] = $( '#auth_settings_oidc_client_secret_' + oidc_num_server ).val();
1203 - params['oidc_scopes_' + oidc_num_server] = $( '#auth_settings_oidc_scopes_' + oidc_num_server ).val();
1204 - params['oidc_prompt_' + oidc_num_server] = $( '#auth_settings_oidc_prompt_' + oidc_num_server ).val();
1205 - params['oidc_login_hint_' + oidc_num_server] = $( '#auth_settings_oidc_login_hint_' + oidc_num_server ).val();
1206 - params['oidc_max_age_' + oidc_num_server] = $( '#auth_settings_oidc_max_age_' + oidc_num_server ).val();
1207 - params['oidc_attr_username_' + oidc_num_server] = $( '#auth_settings_oidc_attr_username_' + oidc_num_server ).val();
1208 - params['oidc_attr_email_' + oidc_num_server] = $( '#auth_settings_oidc_attr_email_' + oidc_num_server ).val();
1209 - params['oidc_attr_first_name_' + oidc_num_server] = $( '#auth_settings_oidc_attr_first_name_' + oidc_num_server ).val();
1210 - params['oidc_attr_last_name_' + oidc_num_server] = $( '#auth_settings_oidc_attr_last_name_' + oidc_num_server ).val();
1211 - params['oidc_attr_update_on_login_' + oidc_num_server] = $( '#auth_settings_oidc_attr_update_on_login_' + oidc_num_server ).val();
1212 - params['oidc_force_auth_method_' + oidc_num_server] = $( '#auth_settings_oidc_force_auth_method_' + oidc_num_server ).val();
1213 - params['oidc_require_verified_email_' + oidc_num_server] = $( '#auth_settings_oidc_require_verified_email_' + oidc_num_server ).is( ':checked' ) ? '1' : '';
1214 - params['oidc_link_on_username_' + oidc_num_server] = $( '#auth_settings_oidc_link_on_username_' + oidc_num_server ).is( ':checked' ) ? '1' : '';
1215 - }
1216 - }
1156 + var google = $( '#auth_settings_google' ).is( ':checked' ) ? '1' : '';
1157 + var google_clientid = $( '#auth_settings_google_clientid' ).val();
1158 + var google_clientsecret = $( '#auth_settings_google_clientsecret' ).val();
1159 + var google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val();
1217 1160
1218 - params.google = $( '#auth_settings_google' ).is( ':checked' ) ? '1' : '';
1219 - params.google_clientid = $( '#auth_settings_google_clientid' ).val();
1220 - params.google_clientsecret = $( '#auth_settings_google_clientsecret' ).val();
1221 - params.google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val();
1161 + var cas = $( '#auth_settings_cas' ).is( ':checked' ) ? '1' : '';
1162 + var cas_custom_label = $( '#auth_settings_cas_custom_label' ).val();
1163 + var cas_host = $( '#auth_settings_cas_host' ).val();
1164 + var cas_port = $( '#auth_settings_cas_port' ).val();
1165 + var cas_path = $( '#auth_settings_cas_path' ).val();
1166 + var cas_version = $( '#auth_settings_cas_version' ).val();
1167 + var cas_attr_email = $( '#auth_settings_cas_attr_email' ).val();
1168 + var cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).val();
1169 + var cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).val();
1170 + var cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).val();
1171 + var cas_auto_login = $( '#auth_settings_cas_auto_login' ).is( ':checked' ) ? '1' : '';
1172 + var cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).is( ':checked' ) ? '1' : '';
1222 1173
1223 - params.cas = $( '#auth_settings_cas' ).is( ':checked' ) ? '1' : '';
1224 - params.cas_auto_login = $( '#auth_settings_cas_auto_login' ).val();
1225 - params.cas_num_servers = parseInt( $( '#auth_settings_cas_num_servers' ).val() );
1226 - params.cas_custom_label = $( '#auth_settings_cas_custom_label' ).val();
1227 - params.cas_host = $( '#auth_settings_cas_host' ).val();
1228 - params.cas_port = $( '#auth_settings_cas_port' ).val();
1229 - params.cas_path = $( '#auth_settings_cas_path' ).val();
1230 - params.cas_method = $( '#auth_settings_cas_method' ).val();
1231 - params.cas_version = $( '#auth_settings_cas_version' ).val();
1232 - params.cas_attr_email = $( '#auth_settings_cas_attr_email' ).val();
1233 - params.cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).val();
1234 - params.cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).val();
1235 - params.cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).val();
1236 - params.cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).is( ':checked' ) ? '1' : '';
1237 - if ( params.cas_num_servers > 1 ) {
1238 - for ( var cas_num_server = 2; cas_num_server <= params.cas_num_servers && cas_num_server <= 10; cas_num_server++ ) {
1239 - params['cas_custom_label_' + cas_num_server] = $( '#auth_settings_cas_custom_label_' + cas_num_server ).val();
1240 - params['cas_host_' + cas_num_server] = $( '#auth_settings_cas_host_' + cas_num_server ).val();
1241 - params['cas_port_' + cas_num_server] = $( '#auth_settings_cas_port_' + cas_num_server ).val();
1242 - params['cas_path_' + cas_num_server] = $( '#auth_settings_cas_path_' + cas_num_server ).val();
1243 - params['cas_method_' + cas_num_server] = $( '#auth_settings_cas_method_' + cas_num_server ).val();
1244 - params['cas_version_' + cas_num_server] = $( '#auth_settings_cas_version_' + cas_num_server ).val();
1245 - params['cas_attr_email_' + cas_num_server] = $( '#auth_settings_cas_attr_email_' + cas_num_server ).val();
1246 - params['cas_attr_first_name_' + cas_num_server] = $( '#auth_settings_cas_attr_first_name_' + cas_num_server ).val();
1247 - params['cas_attr_last_name_' + cas_num_server] = $( '#auth_settings_cas_attr_last_name_' + cas_num_server ).val();
1248 - params['cas_attr_update_on_login_' + cas_num_server] = $( '#auth_settings_cas_attr_update_on_login_' + cas_num_server ).val();
1249 - params['cas_link_on_username_' + cas_num_server] = $( '#auth_settings_cas_link_on_username_' + cas_num_server ).is( ':checked' ) ? '1' : '';
1250 - }
1251 - }
1174 + var ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : '';
1175 + var ldap_host = $( '#auth_settings_ldap_host' ).val();
1176 + var ldap_port = $( '#auth_settings_ldap_port' ).val();
1177 + var ldap_search_base = $( '#auth_settings_ldap_search_base' ).val();
1178 + var ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).val();
1179 + var ldap_uid = $( '#auth_settings_ldap_uid' ).val();
1180 + var ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).val();
1181 + var ldap_user = $( '#auth_settings_ldap_user' ).val();
1182 + var ldap_password = $( '#auth_settings_ldap_password' ).val();
1183 + var ldap_tls = $( '#auth_settings_ldap_tls' ).is( ':checked' ) ? '1' : '';
1184 + var ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).val();
1185 + var ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).val();
1186 + var ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).val();
1187 + var ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).val();
1188 + var ldap_test_user = $( '#auth_settings_ldap_test_user' ).val();
1252 1189
1253 - params.ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : '';
1254 - params.ldap_host = $( '#auth_settings_ldap_host' ).val();
1255 - params.ldap_port = $( '#auth_settings_ldap_port' ).val();
1256 - params.ldap_search_base = $( '#auth_settings_ldap_search_base' ).val();
1257 - params.ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).val();
1258 - params.ldap_uid = $( '#auth_settings_ldap_uid' ).val();
1259 - params.ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).val();
1260 - params.ldap_user = $( '#auth_settings_ldap_user' ).val();
1261 - params.ldap_password = $( '#auth_settings_ldap_password' ).val();
1262 - params.ldap_tls = $( '#auth_settings_ldap_tls' ).is( ':checked' ) ? '1' : '';
1263 - params.ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).val();
1264 - params.ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).val();
1265 - params.ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).val();
1266 - params.ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).val();
1267 - params.ldap_test_user = $( '#auth_settings_ldap_test_user' ).val();
1268 -
1269 - params.advanced_lockouts = {
1190 + var advanced_lockouts = {
1270 1191 attempts_1: $( '#auth_settings_advanced_lockouts_attempts_1' ).val(),
1271 1192 duration_1: $( '#auth_settings_advanced_lockouts_duration_1' ).val(),
1272 1193 attempts_2: $( '#auth_settings_advanced_lockouts_attempts_2' ).val(),
1273 1194 duration_2: $( '#auth_settings_advanced_lockouts_duration_2' ).val(),
@@ -1272,17 +1193,72 @@
1272 1193 attempts_2: $( '#auth_settings_advanced_lockouts_attempts_2' ).val(),
1273 1194 duration_2: $( '#auth_settings_advanced_lockouts_duration_2' ).val(),
1274 1195 reset_duration: $( '#auth_settings_advanced_lockouts_reset_duration' ).val(),
1275 1196 };
1276 - params.advanced_hide_wp_login = $( '#auth_settings_advanced_hide_wp_login' ).is( ':checked' ) ? '1' : '';
1277 - params.advanced_disable_wp_login = $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ? '1' : '';
1278 - params.advanced_disable_wp_login_bypass_usernames = $( '#auth_settings_advanced_disable_wp_login_bypass_usernames' ).val();
1279 - params.advanced_widget_enabled = $( '#auth_settings_advanced_widget_enabled' ).is( ':checked' ) ? '1' : '';
1280 - params.advanced_users_per_page = $( '#auth_settings_advanced_users_per_page' ).val();
1281 - params.advanced_users_sort_by = $( '#auth_settings_advanced_users_sort_by' ).val();
1282 - params.advanced_users_sort_order = $( '#auth_settings_advanced_users_sort_order' ).val();
1197 + var advanced_hide_wp_login = $( '#auth_settings_advanced_hide_wp_login' ).is( ':checked' ) ? '1' : '';
1198 + var advanced_disable_wp_login = $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ? '1' : '';
1199 + var advanced_widget_enabled = $( '#auth_settings_advanced_widget_enabled' ).is( ':checked' ) ? '1' : '';
1200 + var advanced_users_per_page = $( '#auth_settings_advanced_users_per_page' ).val();
1201 + var advanced_users_sort_by = $( '#auth_settings_advanced_users_sort_by' ).val();
1202 + var advanced_users_sort_order = $( '#auth_settings_advanced_users_sort_order' ).val();
1283 1203
1284 - $.post( ajaxurl, params, function( response ) {
1204 + $.post( ajaxurl, {
1205 + action: 'save_auth_multisite_settings',
1206 + nonce: nonce_save_auth_settings,
1207 + multisite_override: multisite_override,
1208 + access_who_can_login: access_who_can_login,
1209 + access_who_can_view: access_who_can_view,
1210 + access_users_approved: access_users_approved,
1211 + access_default_role: access_default_role,
1212 + oauth2: oauth2,
1213 + oauth2_provider: oauth2_provider,
1214 + oauth2_custom_label: oauth2_custom_label,
1215 + oauth2_clientid: oauth2_clientid,
1216 + oauth2_clientsecret: oauth2_clientsecret,
1217 + oauth2_hosteddomain: oauth2_hosteddomain,
1218 + oauth2_tenant_id: oauth2_tenant_id,
1219 + oauth2_url_authorize: oauth2_url_authorize,
1220 + oauth2_url_token: oauth2_url_token,
1221 + oauth2_url_resource: oauth2_url_resource,
1222 + google: google,
1223 + google_clientid: google_clientid,
1224 + google_clientsecret: google_clientsecret,
1225 + google_hosteddomain: google_hosteddomain,
1226 + cas: cas,
1227 + cas_custom_label: cas_custom_label,
1228 + cas_host: cas_host,
1229 + cas_port: cas_port,
1230 + cas_path: cas_path,
1231 + cas_version: cas_version,
1232 + cas_attr_email: cas_attr_email,
1233 + cas_attr_first_name: cas_attr_first_name,
1234 + cas_attr_last_name: cas_attr_last_name,
1235 + cas_attr_update_on_login: cas_attr_update_on_login,
1236 + cas_auto_login: cas_auto_login,
1237 + cas_link_on_username: cas_link_on_username,
1238 + ldap: ldap,
1239 + ldap_host: ldap_host,
1240 + ldap_port: ldap_port,
1241 + ldap_search_base: ldap_search_base,
1242 + ldap_search_filter: ldap_search_filter,
1243 + ldap_uid: ldap_uid,
1244 + ldap_attr_email: ldap_attr_email,
1245 + ldap_user: ldap_user,
1246 + ldap_password: ldap_password,
1247 + ldap_tls: ldap_tls,
1248 + ldap_lostpassword_url: ldap_lostpassword_url,
1249 + ldap_attr_first_name: ldap_attr_first_name,
1250 + ldap_attr_last_name: ldap_attr_last_name,
1251 + ldap_attr_update_on_login: ldap_attr_update_on_login,
1252 + ldap_test_user: ldap_test_user,
1253 + advanced_lockouts: advanced_lockouts,
1254 + advanced_hide_wp_login: advanced_hide_wp_login,
1255 + advanced_disable_wp_login: advanced_disable_wp_login,
1256 + advanced_users_per_page: advanced_users_per_page,
1257 + advanced_users_sort_by: advanced_users_sort_by,
1258 + advanced_users_sort_order: advanced_users_sort_order,
1259 + advanced_widget_enabled: advanced_widget_enabled,
1260 + }, function( response ) {
1285 1261 var succeeded = response === 'success';
1286 1262 var spinnerText = succeeded ? authL10n.saved + '.' : '<span class="attention">' + authL10n.failed + '.</span>';
1287 1263 var spinnerWait = succeeded ? 500 : 2000;
1288 1264 $( 'form .spinner:not(:has(.spinner-text))' ).append( '<span class="spinner-text">' + spinnerText + '</span>' ).delay( spinnerWait ).hide( animationSpeed, function() {
@@ -1291,15 +1267,8 @@
1291 1267 $( caller ).removeAttr( 'disabled' );
1292 1268
1293 1269 // Disable wait cursor.
1294 1270 $( 'html' ).removeClass( 'busy' );
1295 -
1296 - // If the save was successful, and we have more than 1 CAS or OAuth2
1297 - // servers configured, reload the page to render the additional CAS/Oauth2
1298 - // server settings fields.
1299 - if ( succeeded && ( params.cas_num_servers > 1 || params.oauth2_num_servers > 1 ) ) {
1300 - location.reload();
1301 - }
1302 1271 }).fail( function() {
1303 1272 // Fail fires if the server doesn't respond
1304 1273 var succeeded = false;
1305 1274 var spinnerText = succeeded ? authL10n.saved + '.' : '<span class="attention">' + authL10n.failed + '.</span>';