PluginProbe
Authorizer / 3.9.0
Authorizer v3.9.0
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 +180 -167 2.9.133.9.0 View file →
@@ -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 - $( 'div.animated_wrapper', option ).slideDown( animationSpeed );
276 + option.fadeIn( animationSpeed );
277 277 $( 'th, td', option ).removeClass( 'hide-animate hide-no-animate' );
278 278 } else if ( action === 'hide' ) {
279 - $( 'div.animated_wrapper', option ).slideUp( animationSpeed );
279 + option.fadeOut( animationSpeed );
280 280 $( 'td, th', option ).addClass( 'hide-animate' );
281 281 } else if ( action === 'hide_immediately' ) {
282 - $( 'div.animated_wrapper', option ).hide();
282 + option.hide();
283 283 $( 'td, th', option ).addClass( 'hide-no-animate' );
284 284 }
285 285 }
286 286
@@ -382,25 +382,37 @@
382 382 var auth_settings_access_public_pages = $( '#auth_settings_access_public_pages' ).closest( 'tr' );
383 383 var auth_settings_access_redirect_to_login = $( '#radio_auth_settings_access_redirect_to_login' ).closest( 'tr' );
384 384 var auth_settings_access_public_warning = $( '#radio_auth_settings_access_public_warning' ).closest( 'tr' );
385 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' );
395 + var auth_settings_external_oauth2_auto_login = $( '#auth_settings_oauth2_auto_login' ).closest( 'tr' );
386 396 var auth_settings_external_google_clientid = $( '#auth_settings_google_clientid' ).closest( 'tr' );
387 397 var auth_settings_external_google_clientsecret = $( '#auth_settings_google_clientsecret' ).closest( 'tr' );
388 398 var auth_settings_external_google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).closest( 'tr' );
399 + var auth_settings_external_cas_auto_login = $( '#auth_settings_cas_auto_login' ).closest( 'tr' );
389 400 var auth_settings_external_cas_custom_label = $( '#auth_settings_cas_custom_label' ).closest( 'tr' );
390 401 var auth_settings_external_cas_host = $( '#auth_settings_cas_host' ).closest( 'tr' );
391 402 var auth_settings_external_cas_port = $( '#auth_settings_cas_port' ).closest( 'tr' );
392 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' );
393 405 var auth_settings_external_cas_version = $( '#auth_settings_cas_version' ).closest( 'tr' );
394 406 var auth_settings_external_cas_attr_email = $( '#auth_settings_cas_attr_email' ).closest( 'tr' );
395 407 var auth_settings_external_cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).closest( 'tr' );
396 408 var auth_settings_external_cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).closest( 'tr' );
397 409 var auth_settings_external_cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).closest( 'tr' );
398 - var auth_settings_external_cas_auto_login = $( '#auth_settings_cas_auto_login' ).closest( 'tr' );
399 410 var auth_settings_external_cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).closest( 'tr' );
400 411 var auth_settings_external_ldap_host = $( '#auth_settings_ldap_host' ).closest( 'tr' );
401 412 var auth_settings_external_ldap_port = $( '#auth_settings_ldap_port' ).closest( 'tr' );
402 413 var auth_settings_external_ldap_search_base = $( '#auth_settings_ldap_search_base' ).closest( 'tr' );
414 + var auth_settings_external_ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).closest( 'tr' );
403 415 var auth_settings_external_ldap_uid = $( '#auth_settings_ldap_uid' ).closest( 'tr' );
404 416 var auth_settings_external_ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).closest( 'tr' );
405 417 var auth_settings_external_ldap_user = $( '#auth_settings_ldap_user' ).closest( 'tr' );
406 418 var auth_settings_external_ldap_password = $( '#auth_settings_ldap_password' ).closest( 'tr' );
@@ -408,55 +420,11 @@
408 420 var auth_settings_external_ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).closest( 'tr' );
409 421 var auth_settings_external_ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).closest( 'tr' );
410 422 var auth_settings_external_ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).closest( 'tr' );
411 423 var auth_settings_external_ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).closest( 'tr' );
424 + var auth_settings_external_ldap_test_user = $( '#auth_settings_ldap_test_user' ).closest( 'tr' );
412 425 /* eslint-enable */
413 426
414 - // Wrap the th and td in the rows above so we can animate their heights (can't animate tr heights with jquery)
415 - $( 'th, td', auth_settings_access_role_receive_pending_emails ).wrapInner( '<div class="animated_wrapper" />' );
416 - $( 'th, td', auth_settings_access_pending_redirect_to_message ).wrapInner( '<div class="animated_wrapper" />' );
417 - $( 'th, td', auth_settings_access_blocked_redirect_to_message ).wrapInner( '<div class="animated_wrapper" />' );
418 - $( 'th, td', auth_settings_access_should_email_approved_users ).wrapInner( '<div class="animated_wrapper" />' );
419 - $( 'th, td', auth_settings_access_email_approved_users_subject ).wrapInner( '<div class="animated_wrapper" />' );
420 - $( 'th, td', auth_settings_access_email_approved_users_body ).wrapInner( '<div class="animated_wrapper" />' );
421 - $( 'th, td', auth_settings_access_public_pages ).wrapInner( '<div class="animated_wrapper" />' );
422 - $( 'th, td', auth_settings_access_redirect_to_login ).wrapInner( '<div class="animated_wrapper" />' );
423 - $( 'th, td', auth_settings_access_public_warning ).wrapInner( '<div class="animated_wrapper" />' );
424 - $( 'th, td', auth_settings_access_redirect_to_message ).wrapInner( '<div class="animated_wrapper" />' );
425 - $( 'th, td', auth_settings_external_google_clientid ).wrapInner( '<div class="animated_wrapper" />' );
426 - $( 'th, td', auth_settings_external_google_clientsecret ).wrapInner( '<div class="animated_wrapper" />' );
427 - $( 'th, td', auth_settings_external_google_hosteddomain ).wrapInner( '<div class="animated_wrapper" />' );
428 - $( 'th, td', auth_settings_external_cas_custom_label ).wrapInner( '<div class="animated_wrapper" />' );
429 - $( 'th, td', auth_settings_external_cas_host ).wrapInner( '<div class="animated_wrapper" />' );
430 - $( 'th, td', auth_settings_external_cas_port ).wrapInner( '<div class="animated_wrapper" />' );
431 - $( 'th, td', auth_settings_external_cas_path ).wrapInner( '<div class="animated_wrapper" />' );
432 - $( 'th, td', auth_settings_external_cas_version ).wrapInner( '<div class="animated_wrapper" />' );
433 - $( 'th, td', auth_settings_external_cas_attr_email ).wrapInner( '<div class="animated_wrapper" />' );
434 - $( 'th, td', auth_settings_external_cas_attr_first_name ).wrapInner( '<div class="animated_wrapper" />' );
435 - $( 'th, td', auth_settings_external_cas_attr_last_name ).wrapInner( '<div class="animated_wrapper" />' );
436 - $( 'th, td', auth_settings_external_cas_attr_update_on_login ).wrapInner( '<div class="animated_wrapper" />' );
437 - $( 'th, td', auth_settings_external_cas_auto_login ).wrapInner( '<div class="animated_wrapper" />' );
438 - $( 'th, td', auth_settings_external_cas_link_on_username ).wrapInner( '<div class="animated_wrapper" />' );
439 - $( 'th, td', auth_settings_external_ldap_host ).wrapInner( '<div class="animated_wrapper" />' );
440 - $( 'th, td', auth_settings_external_ldap_port ).wrapInner( '<div class="animated_wrapper" />' );
441 - $( 'th, td', auth_settings_external_ldap_search_base ).wrapInner( '<div class="animated_wrapper" />' );
442 - $( 'th, td', auth_settings_external_ldap_uid ).wrapInner( '<div class="animated_wrapper" />' );
443 - $( 'th, td', auth_settings_external_ldap_attr_email ).wrapInner( '<div class="animated_wrapper" />' );
444 - $( 'th, td', auth_settings_external_ldap_user ).wrapInner( '<div class="animated_wrapper" />' );
445 - $( 'th, td', auth_settings_external_ldap_password ).wrapInner( '<div class="animated_wrapper" />' );
446 - $( 'th, td', auth_settings_external_ldap_tls ).wrapInner( '<div class="animated_wrapper" />' );
447 - $( 'th, td', auth_settings_external_ldap_lostpassword_url ).wrapInner( '<div class="animated_wrapper" />' );
448 - $( 'th, td', auth_settings_external_ldap_attr_first_name ).wrapInner( '<div class="animated_wrapper" />' );
449 - $( 'th, td', auth_settings_external_ldap_attr_last_name ).wrapInner( '<div class="animated_wrapper" />' );
450 - $( 'th, td', auth_settings_external_ldap_attr_update_on_login ).wrapInner( '<div class="animated_wrapper" />' );
451 -
452 - // If we're viewing the dashboard widget, reset a couple of the relevant
453 - // option variables (since they aren't nested in table rows).
454 - if ( $( '#auth_dashboard_widget' ).length ) {
455 - // Remove the helper link, since there are no tabs on the dashboard widget
456 - $( '#dashboard_link_approved_users' ).contents().unwrap();
457 - }
458 -
459 427 // Hide settings unless "Only approved users" is checked
460 428 if ( ! $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ) {
461 429 animateOption( 'hide_immediately', auth_settings_access_role_receive_pending_emails );
462 430 animateOption( 'hide_immediately', auth_settings_access_pending_redirect_to_message );
@@ -477,8 +445,30 @@
477 445 animateOption( 'hide_immediately', auth_settings_access_public_warning );
478 446 animateOption( 'hide_immediately', auth_settings_access_redirect_to_message );
479 447 }
480 448
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 + }
458 +
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 + }
465 +
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 );
469 + }
470 +
481 471 // Hide Google options if unchecked
482 472 if ( ! $( '#auth_settings_google' ).is( ':checked' ) ) {
483 473 animateOption( 'hide_immediately', auth_settings_external_google_clientid );
484 474 animateOption( 'hide_immediately', auth_settings_external_google_clientsecret );
@@ -486,18 +476,19 @@
486 476 }
487 477
488 478 // Hide CAS options if unchecked
489 479 if ( ! $( '#auth_settings_cas' ).is( ':checked' ) ) {
480 + animateOption( 'hide_immediately', auth_settings_external_cas_auto_login );
490 481 animateOption( 'hide_immediately', auth_settings_external_cas_custom_label );
491 482 animateOption( 'hide_immediately', auth_settings_external_cas_host );
492 483 animateOption( 'hide_immediately', auth_settings_external_cas_port );
493 484 animateOption( 'hide_immediately', auth_settings_external_cas_path );
485 + animateOption( 'hide_immediately', auth_settings_external_cas_method );
494 486 animateOption( 'hide_immediately', auth_settings_external_cas_version );
495 487 animateOption( 'hide_immediately', auth_settings_external_cas_attr_email );
496 488 animateOption( 'hide_immediately', auth_settings_external_cas_attr_first_name );
497 489 animateOption( 'hide_immediately', auth_settings_external_cas_attr_last_name );
498 490 animateOption( 'hide_immediately', auth_settings_external_cas_attr_update_on_login );
499 - animateOption( 'hide_immediately', auth_settings_external_cas_auto_login );
500 491 animateOption( 'hide_immediately', auth_settings_external_cas_link_on_username );
501 492 }
502 493
503 494 // Hide LDAP options if unchecked
@@ -504,8 +495,9 @@
504 495 if ( ! $( '#auth_settings_ldap' ).is( ':checked' ) ) {
505 496 animateOption( 'hide_immediately', auth_settings_external_ldap_host );
506 497 animateOption( 'hide_immediately', auth_settings_external_ldap_port );
507 498 animateOption( 'hide_immediately', auth_settings_external_ldap_search_base );
499 + animateOption( 'hide_immediately', auth_settings_external_ldap_search_filter );
508 500 animateOption( 'hide_immediately', auth_settings_external_ldap_uid );
509 501 animateOption( 'hide_immediately', auth_settings_external_ldap_attr_email );
510 502 animateOption( 'hide_immediately', auth_settings_external_ldap_user );
511 503 animateOption( 'hide_immediately', auth_settings_external_ldap_password );
@@ -513,12 +505,13 @@
513 505 animateOption( 'hide_immediately', auth_settings_external_ldap_lostpassword_url );
514 506 animateOption( 'hide_immediately', auth_settings_external_ldap_attr_first_name );
515 507 animateOption( 'hide_immediately', auth_settings_external_ldap_attr_last_name );
516 508 animateOption( 'hide_immediately', auth_settings_external_ldap_attr_update_on_login );
509 + animateOption( 'hide_immediately', auth_settings_external_ldap_test_user );
517 510 }
518 511
519 512 // Event handler: Hide "Handle unauthorized visitors" option if access is granted to "Everyone"
520 - $( 'input[name="auth_settings[access_who_can_login]"]' ).change( function() {
513 + $( 'input[name="auth_settings[access_who_can_login]"]' ).on( 'change', function() {
521 514 // Hide settings unless "Only approved users" is checked
522 515 var action = $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ? 'show' : 'hide';
523 516 animateOption( action, auth_settings_access_role_receive_pending_emails );
524 517 animateOption( action, auth_settings_access_pending_redirect_to_message );
@@ -529,9 +522,9 @@
529 522 animateOption( action, auth_settings_access_email_approved_users_body );
530 523 });
531 524
532 525 // Event handler: Hide Welcome email body/subject options if "Send welcome email" is off.
533 - $( 'input[name="auth_settings[access_should_email_approved_users]"]' ).change( function() {
526 + $( 'input[name="auth_settings[access_should_email_approved_users]"]' ).on( 'change', function() {
534 527 var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
535 528 animateOption( action, auth_settings_access_email_approved_users_subject );
536 529 animateOption( action, auth_settings_access_email_approved_users_body );
537 530 });
@@ -536,9 +529,9 @@
536 529 animateOption( action, auth_settings_access_email_approved_users_body );
537 530 });
538 531
539 532 // Event handler: Hide "Handle unauthorized visitors" option if access is granted to "Everyone"
540 - $( 'input[name="auth_settings[access_who_can_view]"]' ).change( function() {
533 + $( 'input[name="auth_settings[access_who_can_view]"]' ).on( 'change', function() {
541 534 var action = $( '#radio_auth_settings_access_who_can_view_everyone' ).is( ':checked' ) ? 'hide' : 'show';
542 535 animateOption( action, auth_settings_access_redirect_to_login );
543 536 animateOption( action, auth_settings_access_redirect_to_message );
544 537 animateOption( action, auth_settings_access_public_pages );
@@ -544,10 +537,31 @@
544 537 animateOption( action, auth_settings_access_public_pages );
545 538 animateOption( action, auth_settings_access_public_warning );
546 539 });
547 540
541 + // Event handler: Show/hide OAuth2 options based on checkbox.
542 + $( 'input[name="auth_settings[oauth2]"]' ).on( 'change', function() {
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 );
550 + });
551 +
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 );
560 + });
561 +
548 562 // Event handler: Show/hide Google options based on checkbox
549 - $( 'input[name="auth_settings[google]"]' ).change( function() {
563 + $( 'input[name="auth_settings[google]"]' ).on( 'change', function() {
550 564 var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
551 565 animateOption( action, auth_settings_external_google_clientid );
552 566 animateOption( action, auth_settings_external_google_clientsecret );
553 567 animateOption( action, auth_settings_external_google_hosteddomain );
@@ -553,29 +567,31 @@
553 567 animateOption( action, auth_settings_external_google_hosteddomain );
554 568 });
555 569
556 570 // Event handler: Show/hide CAS options based on checkbox
557 - $( 'input[name="auth_settings[cas]"]' ).change( function() {
571 + $( 'input[name="auth_settings[cas]"]' ).on( 'change', function() {
558 572 var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
573 + animateOption( action, auth_settings_external_cas_auto_login );
559 574 animateOption( action, auth_settings_external_cas_custom_label );
560 575 animateOption( action, auth_settings_external_cas_host );
561 576 animateOption( action, auth_settings_external_cas_port );
562 577 animateOption( action, auth_settings_external_cas_path );
578 + animateOption( action, auth_settings_external_cas_method );
563 579 animateOption( action, auth_settings_external_cas_version );
564 580 animateOption( action, auth_settings_external_cas_attr_email );
565 581 animateOption( action, auth_settings_external_cas_attr_first_name );
566 582 animateOption( action, auth_settings_external_cas_attr_last_name );
567 583 animateOption( action, auth_settings_external_cas_attr_update_on_login );
568 - animateOption( action, auth_settings_external_cas_auto_login );
569 584 animateOption( action, auth_settings_external_cas_link_on_username );
570 585 });
571 586
572 587 // Event handler: Show/hide LDAP options based on checkbox
573 - $( 'input[name="auth_settings[ldap]"]' ).change( function() {
588 + $( 'input[name="auth_settings[ldap]"]' ).on( 'change', function() {
574 589 var action = $( this ).is( ':checked' ) ? 'show' : 'hide';
575 590 animateOption( action, auth_settings_external_ldap_host );
576 591 animateOption( action, auth_settings_external_ldap_port );
577 592 animateOption( action, auth_settings_external_ldap_search_base );
593 + animateOption( action, auth_settings_external_ldap_search_filter );
578 594 animateOption( action, auth_settings_external_ldap_uid );
579 595 animateOption( action, auth_settings_external_ldap_attr_email );
580 596 animateOption( action, auth_settings_external_ldap_user );
581 597 animateOption( action, auth_settings_external_ldap_password );
@@ -583,10 +599,30 @@
583 599 animateOption( action, auth_settings_external_ldap_lostpassword_url );
584 600 animateOption( action, auth_settings_external_ldap_attr_first_name );
585 601 animateOption( action, auth_settings_external_ldap_attr_last_name );
586 602 animateOption( action, auth_settings_external_ldap_attr_update_on_login );
603 + animateOption( action, auth_settings_external_ldap_test_user );
587 604 });
588 605
606 + // Event handler: Test LDAP settings.
607 + $( '#ldap_test_user_submit' ).on( 'click', function( event ) {
608 + event.preventDefault();
609 + $( 'html' ).addClass( 'busy' );
610 + $( '#ldap_test_user_spinner' ).addClass( 'is-active' );
611 +
612 + $.post( ajaxurl, {
613 + action: 'auth_settings_ldap_test_user',
614 + username: $( 'input[name="auth_settings[ldap_test_user]"]' ).val(),
615 + password: $( 'input#auth_settings_ldap_test_pass' ).val(),
616 + nonce: $( '#nonce_save_auth_settings' ).val(),
617 + }).done( function ( data ) {
618 + $( '#ldap_test_user_result' ).show().val( data.message );
619 + }).always( function () {
620 + $( 'html' ).removeClass( 'busy' );
621 + $( '#ldap_test_user_spinner' ).removeClass( 'is-active' );
622 + });
623 + } );
624 +
589 625 // Show save button if usermeta field is modified.
590 626 $( 'form input.auth-usermeta' ).on( 'keyup', function( event ) {
591 627 // Don't do anything if tab or arrow keys were pressed.
592 628 if ( event.which === 9 || event.which === 37 || event.which === 38 || event.which === 39 || event.which === 40 ) {
@@ -625,22 +661,26 @@
625 661 selectableHeader: '<div class="custom-header">' + authL10n.private_pages + '</div>',
626 662 selectionHeader: '<div class="custom-header">' + authL10n.public_pages + '</div>',
627 663 });
628 664
629 - // Switch to the first tab (or the tab indicated in sessionStorage, or the querystring).
630 - var tab = '';
631 - if ( getQuerystringValuesByKey( 'tab' ).length > 0 ) {
632 - tab = getQuerystringValuesByKey( 'tab' )[0];
633 - } else if ( sessionStorage.getItem( 'tab' ) ) {
634 - tab = sessionStorage.getItem( 'tab' );
665 + // Switch to the first tab (or the tab indicated in sessionStorage, or the
666 + // querystring). Note: only do this on the settings page, not the dashboard
667 + // widget.
668 + if ( ! $( '#auth_dashboard_widget' ).length ) {
669 + var tab = '';
670 + if ( getQuerystringValuesByKey( 'tab' ).length > 0 ) {
671 + tab = getQuerystringValuesByKey( 'tab' )[0];
672 + } else if ( sessionStorage.getItem( 'tab' ) ) {
673 + tab = sessionStorage.getItem( 'tab' );
674 + }
675 + if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'advanced' ] ) < 0 ) {
676 + tab = 'access_lists';
677 + }
678 + window.chooseTab( tab, animationSpeed );
635 679 }
636 - if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'advanced' ] ) < 0 ) {
637 - tab = 'access_lists';
638 - }
639 - window.chooseTab( tab, animationSpeed );
640 680
641 681 // Hide/show multisite settings based on override checkbox.
642 - $( 'input[name="auth_settings[multisite_override]"]' ).change( function() {
682 + $( 'input[name="auth_settings[multisite_override]"]' ).on( 'change', function() {
643 683 hideMultisiteSettingsIfDisabled();
644 684 });
645 685 hideMultisiteSettingsIfDisabled();
646 686
@@ -692,8 +732,10 @@
692 732
693 733 // Enable growable textarea for config fields.
694 734 $( 'textarea#auth_settings_ldap_host' ).autogrow();
695 735 $( 'textarea#auth_settings_ldap_search_base' ).autogrow();
736 + $( 'textarea#auth_settings_ldap_search_filter' ).autogrow();
737 + $( 'textarea#auth_settings_oauth2_hosteddomain' ).autogrow();
696 738 $( 'textarea#auth_settings_google_hosteddomain' ).autogrow();
697 739
698 740 });
699 741
@@ -744,10 +786,8 @@
744 786 'background-color': '#f1f1f1',
745 787 'z-index': 1,
746 788 opacity: 0.8,
747 789 position: 'absolute',
748 - top: optionContainerToHide.position().top,
749 - left: optionContainerToHide.position().left,
750 790 width: '100%',
751 791 height: optionContainerToHide.height(),
752 792 });
753 793 $( this ).show();
@@ -794,9 +834,8 @@
794 834
795 835 // Enable inputs, remove spinner.
796 836 $caller.removeAttr( 'disabled' );
797 837 $usermeta.removeAttr( 'disabled' );
798 - $caller.css( 'display', 'none' );
799 838 $( 'form .spinner:not(:has(.spinner-text))' ).animate( { width: '60px' }, 'fast' ).append( '<span class="spinner-text">' + spinnerText + '</span>' ).delay( spinnerWait ).hide( animationSpeed, function() {
800 839 $( this ).remove();
801 840 });
802 841 $( 'html' ).removeClass( 'busy' );
@@ -808,9 +847,8 @@
808 847
809 848 // Enable inputs, remove spinner.
810 849 $caller.removeAttr( 'disabled' );
811 850 $usermeta.removeAttr( 'disabled' );
812 - $caller.css( 'display', 'none' );
813 851 $( 'form .spinner:not(:has(.spinner-text))' ).animate( { width: '60px' }, 'fast' ).append( '<span class="spinner-text">' + spinnerText + '</span>' ).delay( spinnerWait ).hide( animationSpeed, function() {
814 852 $( this ).remove();
815 853 });
816 854 $( 'html' ).removeClass( 'busy' );
@@ -923,13 +961,12 @@
923 961 })
924 962 );
925 963
926 964 // Add the new item.
927 - var authJsPrefix = isMultisite ? 'authMultisite' : 'auth';
928 - var banButton = ! isMultisite ? '<a class="button' + ( list === 'approved' ? '' : ' invisible' ) + '" id="block_user_' + nextId + '" onclick="' + authJsPrefix + 'AddUser( this, \'blocked\', false ); ' + authJsPrefix + 'IgnoreUser( this, \'approved\' );" title="' + authL10n.block_ban_user + '"><span class="glyphicon glyphicon-ban-circle"></span></a>' : '';
929 - var ignoreButton = '<a class="button" id="ignore_user_' + nextId + '" onclick="' + authJsPrefix + 'IgnoreUser( this, \'' + list + '\' );" title="' + authL10n.remove_user + '"><span class="glyphicon glyphicon-remove"></span></a>';
930 - var localIcon = '&nbsp;<a title="' + authL10n.local_wordpress_user + '" class="auth-local-user' + ( shouldCreateLocalAccount ? '' : ' invisible' ) + '"><span class="glyphicon glyphicon-user"></span></a>';
931 - var multisiteIcon = '&nbsp;<a title="WordPress Multisite user" class="auth-multisite-user'+ ( isMultisite ? '' : ' invisible' ) + '"><span class="glyphicon glyphicon-globe"></span></a>';
965 + var authJsPrefix = isMultisite ? 'authMultisite' : 'auth';
966 + var multisiteIcon = isMultisite ? '<a title="WordPress Multisite user" class="button disabled auth-multisite-user dashicons-before dashicons-admin-site"></a>' : '';
967 + var banButton = isMultisite || 'approved' !== list ? '' : '<a class="button button-primary dashicons-before dashicons-remove" id="block_user_' + nextId + '" onclick="' + authJsPrefix + 'AddUser( this, \'blocked\', false ); ' + authJsPrefix + 'IgnoreUser( this, \'approved\' );" title="' + authL10n.block_ban_user + '"></a>';
968 + var ignoreButton = '<a class="button dashicons-before dashicons-no" id="ignore_user_' + nextId + '" onclick="' + authJsPrefix + 'IgnoreUser( this, \'' + list + '\' );" title="' + authL10n.remove_user + '"></a>';
932 969 $( ' \
933 970 <li id="new_user_' + nextId + '" class="new-user" style="display: none;"> \
934 971 <input type="text" id="auth_settings_access_users_' + list + '_' + nextId + '" name="auth_settings[access_users_' + list + '][' + nextId + '][email]" value="' + user.email + '" readonly="true" class="auth-email" /> \
935 972 <select name="auth_settings[access_users_' + list + '][' + nextId + '][role]" class="auth-role" onchange="' + authJsPrefix + 'ChangeRole( this );"> \
@@ -934,9 +971,9 @@
934 971 <input type="text" id="auth_settings_access_users_' + list + '_' + nextId + '" name="auth_settings[access_users_' + list + '][' + nextId + '][email]" value="' + user.email + '" readonly="true" class="auth-email" /> \
935 972 <select name="auth_settings[access_users_' + list + '][' + nextId + '][role]" class="auth-role" onchange="' + authJsPrefix + 'ChangeRole( this );"> \
936 973 </select> \
937 974 <input type="text" name="auth_settings[access_users_' + list + '][' + nextId + '][date_added]" value="' + getShortDate() + '" readonly="true" class="auth-date-added" /> \
938 - ' + banButton + ignoreButton + localIcon + multisiteIcon + ' \
975 + ' + multisiteIcon + banButton + ignoreButton + ' \
939 976 <span class="spinner is-active"></span> \
940 977 </li> \
941 978 ' ).appendTo( '#list_auth_settings_access_users_' + list ).slideDown( 250 );
942 979
@@ -1040,18 +1077,23 @@
1040 1077 left: $( caller ).position().left + $( caller ).width() + 20,
1041 1078 });
1042 1079 $( caller ).after( $spinner );
1043 1080
1044 - // Get form elements to save
1045 - var nonce_save_auth_settings = $( '#nonce_save_auth_settings' ).val();
1081 + // Get form elements to save.
1082 + var params = {
1083 + action: 'save_auth_multisite_settings',
1084 + nonce: $( '#nonce_save_auth_settings' ).val(),
1085 + };
1046 1086
1047 - var multisite_override = $( '#auth_settings_multisite_override' ).is( ':checked' ) ? '1' : '';
1087 + params.multisite_override = $( '#auth_settings_multisite_override' ).is( ':checked' ) ? '1' : '';
1048 1088
1049 - var access_who_can_login = $( 'form input[name="auth_settings[access_who_can_login]"]:checked' ).val();
1089 + params.prevent_override_multisite = $( '#auth_settings_prevent_override_multisite' ).is( ':checked' ) ? '1' : '';
1050 1090
1051 - var access_who_can_view = $( 'form input[name="auth_settings[access_who_can_view]"]:checked' ).val();
1091 + params.access_who_can_login = $( 'form input[name="auth_settings[access_who_can_login]"]:checked' ).val();
1052 1092
1053 - var access_users_approved = {};
1093 + params.access_who_can_view = $( 'form input[name="auth_settings[access_who_can_view]"]:checked' ).val();
1094 +
1095 + params.access_users_approved = {};
1054 1096 $( '#list_auth_settings_access_users_approved li' ).each( function( index ) {
1055 1097 var user = {};
1056 1098 user.email = $( '.auth-email', this ).val();
1057 1099 user.role = $( '.auth-role', this ).val();
@@ -1056,46 +1098,61 @@
1056 1098 user.email = $( '.auth-email', this ).val();
1057 1099 user.role = $( '.auth-role', this ).val();
1058 1100 user.date_added = $( '.auth-date-added', this ).val();
1059 1101 user.local_user = $( '.auth-local-user', this ).length !== 0;
1060 - access_users_approved[index] = user;
1102 + params.access_users_approved[index] = user;
1061 1103 });
1062 1104
1063 - var access_default_role = $( '#auth_settings_access_default_role' ).val();
1105 + params.access_default_role = $( '#auth_settings_access_default_role' ).val();
1064 1106
1065 - var google = $( '#auth_settings_google' ).is( ':checked' ) ? '1' : '';
1066 - var google_clientid = $( '#auth_settings_google_clientid' ).val();
1067 - var google_clientsecret = $( '#auth_settings_google_clientsecret' ).val();
1068 - var google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val();
1107 + params.oauth2 = $( '#auth_settings_oauth2' ).is( ':checked' ) ? '1' : '';
1108 + params.oauth2_provider = $( '#auth_settings_oauth2_provider' ).val();
1109 + params.oauth2_custom_label = $( '#auth_settings_oauth2_custom_label' ).val();
1110 + params.oauth2_clientid = $( '#auth_settings_oauth2_clientid' ).val();
1111 + params.oauth2_clientsecret = $( '#auth_settings_oauth2_clientsecret' ).val();
1112 + params.oauth2_hosteddomain = $( '#auth_settings_oauth2_hosteddomain' ).val();
1113 + params.oauth2_tenant_id = $( '#auth_settings_oauth2_tenant_id' ).val();
1114 + params.oauth2_url_authorize = $( '#auth_settings_oauth2_url_authorize' ).val();
1115 + params.oauth2_url_token = $( '#auth_settings_oauth2_url_token' ).val();
1116 + params.oauth2_url_resource = $( '#auth_settings_oauth2_url_resource' ).val();
1117 + params.oauth2_auto_login = $( '#auth_settings_oauth2_auto_login' ).is( ':checked' ) ? '1' : '';
1069 1118
1070 - var cas = $( '#auth_settings_cas' ).is( ':checked' ) ? '1' : '';
1071 - var cas_custom_label = $( '#auth_settings_cas_custom_label' ).val();
1072 - var cas_host = $( '#auth_settings_cas_host' ).val();
1073 - var cas_port = $( '#auth_settings_cas_port' ).val();
1074 - var cas_path = $( '#auth_settings_cas_path' ).val();
1075 - var cas_version = $( '#auth_settings_cas_version' ).val();
1076 - var cas_attr_email = $( '#auth_settings_cas_attr_email' ).val();
1077 - var cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).val();
1078 - var cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).val();
1079 - var cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).is( ':checked' ) ? '1' : '';
1080 - var cas_auto_login = $( '#auth_settings_cas_auto_login' ).is( ':checked' ) ? '1' : '';
1081 - var cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).is( ':checked' ) ? '1' : '';
1119 + params.google = $( '#auth_settings_google' ).is( ':checked' ) ? '1' : '';
1120 + params.google_clientid = $( '#auth_settings_google_clientid' ).val();
1121 + params.google_clientsecret = $( '#auth_settings_google_clientsecret' ).val();
1122 + params.google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val();
1082 1123
1083 - var ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : '';
1084 - var ldap_host = $( '#auth_settings_ldap_host' ).val();
1085 - var ldap_port = $( '#auth_settings_ldap_port' ).val();
1086 - var ldap_search_base = $( '#auth_settings_ldap_search_base' ).val();
1087 - var ldap_uid = $( '#auth_settings_ldap_uid' ).val();
1088 - var ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).val();
1089 - var ldap_user = $( '#auth_settings_ldap_user' ).val();
1090 - var ldap_password = $( '#auth_settings_ldap_password' ).val();
1091 - var ldap_tls = $( '#auth_settings_ldap_tls' ).is( ':checked' ) ? '1' : '';
1092 - var ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).val();
1093 - var ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).val();
1094 - var ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).val();
1095 - var ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).is( ':checked' ) ? '1' : '';
1124 + params.cas = $( '#auth_settings_cas' ).is( ':checked' ) ? '1' : '';
1125 + params.cas_auto_login = $( '#auth_settings_cas_auto_login' ).is( ':checked' ) ? '1' : '';
1126 + params.cas_custom_label = $( '#auth_settings_cas_custom_label' ).val();
1127 + params.cas_host = $( '#auth_settings_cas_host' ).val();
1128 + params.cas_port = $( '#auth_settings_cas_port' ).val();
1129 + params.cas_path = $( '#auth_settings_cas_path' ).val();
1130 + params.cas_method = $( '#auth_settings_cas_method' ).val();
1131 + params.cas_version = $( '#auth_settings_cas_version' ).val();
1132 + params.cas_attr_email = $( '#auth_settings_cas_attr_email' ).val();
1133 + params.cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).val();
1134 + params.cas_attr_last_name = $( '#auth_settings_cas_attr_last_name' ).val();
1135 + params.cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).val();
1136 + params.cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).is( ':checked' ) ? '1' : '';
1096 1137
1097 - var advanced_lockouts = {
1138 + params.ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : '';
1139 + params.ldap_host = $( '#auth_settings_ldap_host' ).val();
1140 + params.ldap_port = $( '#auth_settings_ldap_port' ).val();
1141 + params.ldap_search_base = $( '#auth_settings_ldap_search_base' ).val();
1142 + params.ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).val();
1143 + params.ldap_uid = $( '#auth_settings_ldap_uid' ).val();
1144 + params.ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).val();
1145 + params.ldap_user = $( '#auth_settings_ldap_user' ).val();
1146 + params.ldap_password = $( '#auth_settings_ldap_password' ).val();
1147 + params.ldap_tls = $( '#auth_settings_ldap_tls' ).is( ':checked' ) ? '1' : '';
1148 + params.ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).val();
1149 + params.ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).val();
1150 + params.ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).val();
1151 + params.ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).val();
1152 + params.ldap_test_user = $( '#auth_settings_ldap_test_user' ).val();
1153 +
1154 + params.advanced_lockouts = {
1098 1155 attempts_1: $( '#auth_settings_advanced_lockouts_attempts_1' ).val(),
1099 1156 duration_1: $( '#auth_settings_advanced_lockouts_duration_1' ).val(),
1100 1157 attempts_2: $( '#auth_settings_advanced_lockouts_attempts_2' ).val(),
1101 1158 duration_2: $( '#auth_settings_advanced_lockouts_duration_2' ).val(),
@@ -1100,60 +1157,16 @@
1100 1157 attempts_2: $( '#auth_settings_advanced_lockouts_attempts_2' ).val(),
1101 1158 duration_2: $( '#auth_settings_advanced_lockouts_duration_2' ).val(),
1102 1159 reset_duration: $( '#auth_settings_advanced_lockouts_reset_duration' ).val(),
1103 1160 };
1104 - var advanced_hide_wp_login = $( '#auth_settings_advanced_hide_wp_login' ).is( ':checked' ) ? '1' : '';
1105 - var advanced_disable_wp_login = $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ? '1' : '';
1106 - var advanced_widget_enabled = $( '#auth_settings_advanced_widget_enabled' ).is( ':checked' ) ? '1' : '';
1107 - var advanced_users_per_page = $( '#auth_settings_advanced_users_per_page' ).val();
1108 - var advanced_users_sort_by = $( '#auth_settings_advanced_users_sort_by' ).val();
1109 - var advanced_users_sort_order = $( '#auth_settings_advanced_users_sort_order' ).val();
1161 + params.advanced_hide_wp_login = $( '#auth_settings_advanced_hide_wp_login' ).is( ':checked' ) ? '1' : '';
1162 + params.advanced_disable_wp_login = $( '#auth_settings_advanced_disable_wp_login' ).is( ':checked' ) ? '1' : '';
1163 + params.advanced_widget_enabled = $( '#auth_settings_advanced_widget_enabled' ).is( ':checked' ) ? '1' : '';
1164 + params.advanced_users_per_page = $( '#auth_settings_advanced_users_per_page' ).val();
1165 + params.advanced_users_sort_by = $( '#auth_settings_advanced_users_sort_by' ).val();
1166 + params.advanced_users_sort_order = $( '#auth_settings_advanced_users_sort_order' ).val();
1110 1167
1111 - $.post( ajaxurl, {
1112 - action: 'save_auth_multisite_settings',
1113 - nonce: nonce_save_auth_settings,
1114 - multisite_override: multisite_override,
1115 - access_who_can_login: access_who_can_login,
1116 - access_who_can_view: access_who_can_view,
1117 - access_users_approved: access_users_approved,
1118 - access_default_role: access_default_role,
1119 - google: google,
1120 - google_clientid: google_clientid,
1121 - google_clientsecret: google_clientsecret,
1122 - google_hosteddomain: google_hosteddomain,
1123 - cas: cas,
1124 - cas_custom_label: cas_custom_label,
1125 - cas_host: cas_host,
1126 - cas_port: cas_port,
1127 - cas_path: cas_path,
1128 - cas_version: cas_version,
1129 - cas_attr_email: cas_attr_email,
1130 - cas_attr_first_name: cas_attr_first_name,
1131 - cas_attr_last_name: cas_attr_last_name,
1132 - cas_attr_update_on_login: cas_attr_update_on_login,
1133 - cas_auto_login: cas_auto_login,
1134 - cas_link_on_username: cas_link_on_username,
1135 - ldap: ldap,
1136 - ldap_host: ldap_host,
1137 - ldap_port: ldap_port,
1138 - ldap_search_base: ldap_search_base,
1139 - ldap_uid: ldap_uid,
1140 - ldap_attr_email: ldap_attr_email,
1141 - ldap_user: ldap_user,
1142 - ldap_password: ldap_password,
1143 - ldap_tls: ldap_tls,
1144 - ldap_lostpassword_url: ldap_lostpassword_url,
1145 - ldap_attr_first_name: ldap_attr_first_name,
1146 - ldap_attr_last_name: ldap_attr_last_name,
1147 - ldap_attr_update_on_login: ldap_attr_update_on_login,
1148 - advanced_lockouts: advanced_lockouts,
1149 - advanced_hide_wp_login: advanced_hide_wp_login,
1150 - advanced_disable_wp_login: advanced_disable_wp_login,
1151 - advanced_users_per_page: advanced_users_per_page,
1152 - advanced_users_sort_by: advanced_users_sort_by,
1153 - advanced_users_sort_order: advanced_users_sort_order,
1154 - advanced_widget_enabled: advanced_widget_enabled,
1155 - }, function( response ) {
1168 + $.post( ajaxurl, params, function( response ) {
1156 1169 var succeeded = response === 'success';
1157 1170 var spinnerText = succeeded ? authL10n.saved + '.' : '<span class="attention">' + authL10n.failed + '.</span>';
1158 1171 var spinnerWait = succeeded ? 500 : 2000;
1159 1172 $( 'form .spinner:not(:has(.spinner-text))' ).append( '<span class="spinner-text">' + spinnerText + '</span>' ).delay( spinnerWait ).hide( animationSpeed, function() {