| @@ -382,8 +382,17 @@ | ||
| 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' ); | |
| 386 | 395 | var auth_settings_external_google_clientid = $( '#auth_settings_google_clientid' ).closest( 'tr' ); |
| 387 | 396 | var auth_settings_external_google_clientsecret = $( '#auth_settings_google_clientsecret' ).closest( 'tr' ); |
| 388 | 397 | var auth_settings_external_google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).closest( 'tr' ); |
| 389 | 398 | var auth_settings_external_cas_custom_label = $( '#auth_settings_cas_custom_label' ).closest( 'tr' ); |
| @@ -399,8 +408,9 @@ | ||
| 399 | 408 | var auth_settings_external_cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).closest( 'tr' ); |
| 400 | 409 | var auth_settings_external_ldap_host = $( '#auth_settings_ldap_host' ).closest( 'tr' ); |
| 401 | 410 | var auth_settings_external_ldap_port = $( '#auth_settings_ldap_port' ).closest( 'tr' ); |
| 402 | 411 | var auth_settings_external_ldap_search_base = $( '#auth_settings_ldap_search_base' ).closest( 'tr' ); |
| 412 | + var auth_settings_external_ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).closest( 'tr' ); | |
| 403 | 413 | var auth_settings_external_ldap_uid = $( '#auth_settings_ldap_uid' ).closest( 'tr' ); |
| 404 | 414 | var auth_settings_external_ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).closest( 'tr' ); |
| 405 | 415 | var auth_settings_external_ldap_user = $( '#auth_settings_ldap_user' ).closest( 'tr' ); |
| 406 | 416 | var auth_settings_external_ldap_password = $( '#auth_settings_ldap_password' ).closest( 'tr' ); |
| @@ -408,8 +418,9 @@ | ||
| 408 | 418 | var auth_settings_external_ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).closest( 'tr' ); |
| 409 | 419 | var auth_settings_external_ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).closest( 'tr' ); |
| 410 | 420 | var auth_settings_external_ldap_attr_last_name = $( '#auth_settings_ldap_attr_last_name' ).closest( 'tr' ); |
| 411 | 421 | var auth_settings_external_ldap_attr_update_on_login = $( '#auth_settings_ldap_attr_update_on_login' ).closest( 'tr' ); |
| 422 | + var auth_settings_external_ldap_test_user = $( '#auth_settings_ldap_test_user' ).closest( 'tr' ); | |
| 412 | 423 | /* eslint-enable */ |
| 413 | 424 | |
| 414 | 425 | // Wrap the th and td in the rows above so we can animate their heights (can't animate tr heights with jquery) |
| 415 | 426 | $( 'th, td', auth_settings_access_role_receive_pending_emails ).wrapInner( '<div class="animated_wrapper" />' ); |
| @@ -421,8 +432,17 @@ | ||
| 421 | 432 | $( 'th, td', auth_settings_access_public_pages ).wrapInner( '<div class="animated_wrapper" />' ); |
| 422 | 433 | $( 'th, td', auth_settings_access_redirect_to_login ).wrapInner( '<div class="animated_wrapper" />' ); |
| 423 | 434 | $( 'th, td', auth_settings_access_public_warning ).wrapInner( '<div class="animated_wrapper" />' ); |
| 424 | 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" />' ); | |
| 425 | 445 | $( 'th, td', auth_settings_external_google_clientid ).wrapInner( '<div class="animated_wrapper" />' ); |
| 426 | 446 | $( 'th, td', auth_settings_external_google_clientsecret ).wrapInner( '<div class="animated_wrapper" />' ); |
| 427 | 447 | $( 'th, td', auth_settings_external_google_hosteddomain ).wrapInner( '<div class="animated_wrapper" />' ); |
| 428 | 448 | $( 'th, td', auth_settings_external_cas_custom_label ).wrapInner( '<div class="animated_wrapper" />' ); |
| @@ -438,8 +458,9 @@ | ||
| 438 | 458 | $( 'th, td', auth_settings_external_cas_link_on_username ).wrapInner( '<div class="animated_wrapper" />' ); |
| 439 | 459 | $( 'th, td', auth_settings_external_ldap_host ).wrapInner( '<div class="animated_wrapper" />' ); |
| 440 | 460 | $( 'th, td', auth_settings_external_ldap_port ).wrapInner( '<div class="animated_wrapper" />' ); |
| 441 | 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" />' ); | |
| 442 | 463 | $( 'th, td', auth_settings_external_ldap_uid ).wrapInner( '<div class="animated_wrapper" />' ); |
| 443 | 464 | $( 'th, td', auth_settings_external_ldap_attr_email ).wrapInner( '<div class="animated_wrapper" />' ); |
| 444 | 465 | $( 'th, td', auth_settings_external_ldap_user ).wrapInner( '<div class="animated_wrapper" />' ); |
| 445 | 466 | $( 'th, td', auth_settings_external_ldap_password ).wrapInner( '<div class="animated_wrapper" />' ); |
| @@ -447,16 +468,10 @@ | ||
| 447 | 468 | $( 'th, td', auth_settings_external_ldap_lostpassword_url ).wrapInner( '<div class="animated_wrapper" />' ); |
| 448 | 469 | $( 'th, td', auth_settings_external_ldap_attr_first_name ).wrapInner( '<div class="animated_wrapper" />' ); |
| 449 | 470 | $( 'th, td', auth_settings_external_ldap_attr_last_name ).wrapInner( '<div class="animated_wrapper" />' ); |
| 450 | 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" />' ); | |
| 451 | 473 | |
| 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 | 474 | // Hide settings unless "Only approved users" is checked |
| 460 | 475 | if ( ! $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ) { |
| 461 | 476 | animateOption( 'hide_immediately', auth_settings_access_role_receive_pending_emails ); |
| 462 | 477 | animateOption( 'hide_immediately', auth_settings_access_pending_redirect_to_message ); |
| @@ -477,8 +492,29 @@ | ||
| 477 | 492 | animateOption( 'hide_immediately', auth_settings_access_public_warning ); |
| 478 | 493 | animateOption( 'hide_immediately', auth_settings_access_redirect_to_message ); |
| 479 | 494 | } |
| 480 | 495 | |
| 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 | + } | |
| 504 | + | |
| 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 | + } | |
| 511 | + | |
| 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 ); | |
| 515 | + } | |
| 516 | + | |
| 481 | 517 | // Hide Google options if unchecked |
| 482 | 518 | if ( ! $( '#auth_settings_google' ).is( ':checked' ) ) { |
| 483 | 519 | animateOption( 'hide_immediately', auth_settings_external_google_clientid ); |
| 484 | 520 | animateOption( 'hide_immediately', auth_settings_external_google_clientsecret ); |
| @@ -504,8 +540,9 @@ | ||
| 504 | 540 | if ( ! $( '#auth_settings_ldap' ).is( ':checked' ) ) { |
| 505 | 541 | animateOption( 'hide_immediately', auth_settings_external_ldap_host ); |
| 506 | 542 | animateOption( 'hide_immediately', auth_settings_external_ldap_port ); |
| 507 | 543 | animateOption( 'hide_immediately', auth_settings_external_ldap_search_base ); |
| 544 | + animateOption( 'hide_immediately', auth_settings_external_ldap_search_filter ); | |
| 508 | 545 | animateOption( 'hide_immediately', auth_settings_external_ldap_uid ); |
| 509 | 546 | animateOption( 'hide_immediately', auth_settings_external_ldap_attr_email ); |
| 510 | 547 | animateOption( 'hide_immediately', auth_settings_external_ldap_user ); |
| 511 | 548 | animateOption( 'hide_immediately', auth_settings_external_ldap_password ); |
| @@ -513,12 +550,13 @@ | ||
| 513 | 550 | animateOption( 'hide_immediately', auth_settings_external_ldap_lostpassword_url ); |
| 514 | 551 | animateOption( 'hide_immediately', auth_settings_external_ldap_attr_first_name ); |
| 515 | 552 | animateOption( 'hide_immediately', auth_settings_external_ldap_attr_last_name ); |
| 516 | 553 | animateOption( 'hide_immediately', auth_settings_external_ldap_attr_update_on_login ); |
| 554 | + animateOption( 'hide_immediately', auth_settings_external_ldap_test_user ); | |
| 517 | 555 | } |
| 518 | 556 | |
| 519 | 557 | // Event handler: Hide "Handle unauthorized visitors" option if access is granted to "Everyone" |
| 520 | - $( 'input[name="auth_settings[access_who_can_login]"]' ).change( function() { | |
| 558 | + $( 'input[name="auth_settings[access_who_can_login]"]' ).on( 'change', function() { | |
| 521 | 559 | // Hide settings unless "Only approved users" is checked |
| 522 | 560 | var action = $( '#radio_auth_settings_access_who_can_login_approved_users' ).is( ':checked' ) ? 'show' : 'hide'; |
| 523 | 561 | animateOption( action, auth_settings_access_role_receive_pending_emails ); |
| 524 | 562 | animateOption( action, auth_settings_access_pending_redirect_to_message ); |
| @@ -529,9 +567,9 @@ | ||
| 529 | 567 | animateOption( action, auth_settings_access_email_approved_users_body ); |
| 530 | 568 | }); |
| 531 | 569 | |
| 532 | 570 | // 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() { | |
| 571 | + $( 'input[name="auth_settings[access_should_email_approved_users]"]' ).on( 'change', function() { | |
| 534 | 572 | var action = $( this ).is( ':checked' ) ? 'show' : 'hide'; |
| 535 | 573 | animateOption( action, auth_settings_access_email_approved_users_subject ); |
| 536 | 574 | animateOption( action, auth_settings_access_email_approved_users_body ); |
| 537 | 575 | }); |
| @@ -536,9 +574,9 @@ | ||
| 536 | 574 | animateOption( action, auth_settings_access_email_approved_users_body ); |
| 537 | 575 | }); |
| 538 | 576 | |
| 539 | 577 | // Event handler: Hide "Handle unauthorized visitors" option if access is granted to "Everyone" |
| 540 | - $( 'input[name="auth_settings[access_who_can_view]"]' ).change( function() { | |
| 578 | + $( 'input[name="auth_settings[access_who_can_view]"]' ).on( 'change', function() { | |
| 541 | 579 | var action = $( '#radio_auth_settings_access_who_can_view_everyone' ).is( ':checked' ) ? 'hide' : 'show'; |
| 542 | 580 | animateOption( action, auth_settings_access_redirect_to_login ); |
| 543 | 581 | animateOption( action, auth_settings_access_redirect_to_message ); |
| 544 | 582 | animateOption( action, auth_settings_access_public_pages ); |
| @@ -544,10 +582,30 @@ | ||
| 544 | 582 | animateOption( action, auth_settings_access_public_pages ); |
| 545 | 583 | animateOption( action, auth_settings_access_public_warning ); |
| 546 | 584 | }); |
| 547 | 585 | |
| 586 | + // Event handler: Show/hide OAuth2 options based on checkbox. | |
| 587 | + $( 'input[name="auth_settings[oauth2]"]' ).on( 'change', function() { | |
| 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 ); | |
| 594 | + }); | |
| 595 | + | |
| 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 ); | |
| 604 | + }); | |
| 605 | + | |
| 548 | 606 | // Event handler: Show/hide Google options based on checkbox |
| 549 | - $( 'input[name="auth_settings[google]"]' ).change( function() { | |
| 607 | + $( 'input[name="auth_settings[google]"]' ).on( 'change', function() { | |
| 550 | 608 | var action = $( this ).is( ':checked' ) ? 'show' : 'hide'; |
| 551 | 609 | animateOption( action, auth_settings_external_google_clientid ); |
| 552 | 610 | animateOption( action, auth_settings_external_google_clientsecret ); |
| 553 | 611 | animateOption( action, auth_settings_external_google_hosteddomain ); |
| @@ -553,9 +611,9 @@ | ||
| 553 | 611 | animateOption( action, auth_settings_external_google_hosteddomain ); |
| 554 | 612 | }); |
| 555 | 613 | |
| 556 | 614 | // Event handler: Show/hide CAS options based on checkbox |
| 557 | - $( 'input[name="auth_settings[cas]"]' ).change( function() { | |
| 615 | + $( 'input[name="auth_settings[cas]"]' ).on( 'change', function() { | |
| 558 | 616 | var action = $( this ).is( ':checked' ) ? 'show' : 'hide'; |
| 559 | 617 | animateOption( action, auth_settings_external_cas_custom_label ); |
| 560 | 618 | animateOption( action, auth_settings_external_cas_host ); |
| 561 | 619 | animateOption( action, auth_settings_external_cas_port ); |
| @@ -569,13 +627,14 @@ | ||
| 569 | 627 | animateOption( action, auth_settings_external_cas_link_on_username ); |
| 570 | 628 | }); |
| 571 | 629 | |
| 572 | 630 | // Event handler: Show/hide LDAP options based on checkbox |
| 573 | - $( 'input[name="auth_settings[ldap]"]' ).change( function() { | |
| 631 | + $( 'input[name="auth_settings[ldap]"]' ).on( 'change', function() { | |
| 574 | 632 | var action = $( this ).is( ':checked' ) ? 'show' : 'hide'; |
| 575 | 633 | animateOption( action, auth_settings_external_ldap_host ); |
| 576 | 634 | animateOption( action, auth_settings_external_ldap_port ); |
| 577 | 635 | animateOption( action, auth_settings_external_ldap_search_base ); |
| 636 | + animateOption( action, auth_settings_external_ldap_search_filter ); | |
| 578 | 637 | animateOption( action, auth_settings_external_ldap_uid ); |
| 579 | 638 | animateOption( action, auth_settings_external_ldap_attr_email ); |
| 580 | 639 | animateOption( action, auth_settings_external_ldap_user ); |
| 581 | 640 | animateOption( action, auth_settings_external_ldap_password ); |
| @@ -583,10 +642,30 @@ | ||
| 583 | 642 | animateOption( action, auth_settings_external_ldap_lostpassword_url ); |
| 584 | 643 | animateOption( action, auth_settings_external_ldap_attr_first_name ); |
| 585 | 644 | animateOption( action, auth_settings_external_ldap_attr_last_name ); |
| 586 | 645 | animateOption( action, auth_settings_external_ldap_attr_update_on_login ); |
| 646 | + animateOption( action, auth_settings_external_ldap_test_user ); | |
| 587 | 647 | }); |
| 588 | 648 | |
| 649 | + // Event handler: Test LDAP settings. | |
| 650 | + $( '#ldap_test_user_submit' ).on( 'click', function( event ) { | |
| 651 | + event.preventDefault(); | |
| 652 | + $( 'html' ).addClass( 'busy' ); | |
| 653 | + $( '#ldap_test_user_spinner' ).addClass( 'is-active' ); | |
| 654 | + | |
| 655 | + $.post( ajaxurl, { | |
| 656 | + action: 'auth_settings_ldap_test_user', | |
| 657 | + username: $( 'input[name="auth_settings[ldap_test_user]"]' ).val(), | |
| 658 | + password: $( 'input#auth_settings_ldap_test_pass' ).val(), | |
| 659 | + nonce: $( '#nonce_save_auth_settings' ).val(), | |
| 660 | + }).done( function ( data ) { | |
| 661 | + $( '#ldap_test_user_result' ).show().val( data.message ); | |
| 662 | + }).always( function () { | |
| 663 | + $( 'html' ).removeClass( 'busy' ); | |
| 664 | + $( '#ldap_test_user_spinner' ).removeClass( 'is-active' ); | |
| 665 | + }); | |
| 666 | + } ); | |
| 667 | + | |
| 589 | 668 | // Show save button if usermeta field is modified. |
| 590 | 669 | $( 'form input.auth-usermeta' ).on( 'keyup', function( event ) { |
| 591 | 670 | // Don't do anything if tab or arrow keys were pressed. |
| 592 | 671 | if ( event.which === 9 || event.which === 37 || event.which === 38 || event.which === 39 || event.which === 40 ) { |
| @@ -625,22 +704,26 @@ | ||
| 625 | 704 | selectableHeader: '<div class="custom-header">' + authL10n.private_pages + '</div>', |
| 626 | 705 | selectionHeader: '<div class="custom-header">' + authL10n.public_pages + '</div>', |
| 627 | 706 | }); |
| 628 | 707 | |
| 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' ); | |
| 708 | + // Switch to the first tab (or the tab indicated in sessionStorage, or the | |
| 709 | + // querystring). Note: only do this on the settings page, not the dashboard | |
| 710 | + // widget. | |
| 711 | + if ( ! $( '#auth_dashboard_widget' ).length ) { | |
| 712 | + var tab = ''; | |
| 713 | + if ( getQuerystringValuesByKey( 'tab' ).length > 0 ) { | |
| 714 | + tab = getQuerystringValuesByKey( 'tab' )[0]; | |
| 715 | + } else if ( sessionStorage.getItem( 'tab' ) ) { | |
| 716 | + tab = sessionStorage.getItem( 'tab' ); | |
| 717 | + } | |
| 718 | + if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'advanced' ] ) < 0 ) { | |
| 719 | + tab = 'access_lists'; | |
| 720 | + } | |
| 721 | + window.chooseTab( tab, animationSpeed ); | |
| 635 | 722 | } |
| 636 | - if ( $.inArray( tab, [ 'access_lists', 'access_login', 'access_public', 'external', 'advanced' ] ) < 0 ) { | |
| 637 | - tab = 'access_lists'; | |
| 638 | - } | |
| 639 | - window.chooseTab( tab, animationSpeed ); | |
| 640 | 723 | |
| 641 | 724 | // Hide/show multisite settings based on override checkbox. |
| 642 | - $( 'input[name="auth_settings[multisite_override]"]' ).change( function() { | |
| 725 | + $( 'input[name="auth_settings[multisite_override]"]' ).on( 'change', function() { | |
| 643 | 726 | hideMultisiteSettingsIfDisabled(); |
| 644 | 727 | }); |
| 645 | 728 | hideMultisiteSettingsIfDisabled(); |
| 646 | 729 | |
| @@ -692,8 +775,10 @@ | ||
| 692 | 775 | |
| 693 | 776 | // Enable growable textarea for config fields. |
| 694 | 777 | $( 'textarea#auth_settings_ldap_host' ).autogrow(); |
| 695 | 778 | $( 'textarea#auth_settings_ldap_search_base' ).autogrow(); |
| 779 | + $( 'textarea#auth_settings_ldap_search_filter' ).autogrow(); | |
| 780 | + $( 'textarea#auth_settings_oauth2_hosteddomain' ).autogrow(); | |
| 696 | 781 | $( 'textarea#auth_settings_google_hosteddomain' ).autogrow(); |
| 697 | 782 | |
| 698 | 783 | }); |
| 699 | 784 | |
| @@ -744,10 +829,8 @@ | ||
| 744 | 829 | 'background-color': '#f1f1f1', |
| 745 | 830 | 'z-index': 1, |
| 746 | 831 | opacity: 0.8, |
| 747 | 832 | position: 'absolute', |
| 748 | - top: optionContainerToHide.position().top, | |
| 749 | - left: optionContainerToHide.position().left, | |
| 750 | 833 | width: '100%', |
| 751 | 834 | height: optionContainerToHide.height(), |
| 752 | 835 | }); |
| 753 | 836 | $( this ).show(); |
| @@ -794,9 +877,8 @@ | ||
| 794 | 877 | |
| 795 | 878 | // Enable inputs, remove spinner. |
| 796 | 879 | $caller.removeAttr( 'disabled' ); |
| 797 | 880 | $usermeta.removeAttr( 'disabled' ); |
| 798 | - $caller.css( 'display', 'none' ); | |
| 799 | 881 | $( 'form .spinner:not(:has(.spinner-text))' ).animate( { width: '60px' }, 'fast' ).append( '<span class="spinner-text">' + spinnerText + '</span>' ).delay( spinnerWait ).hide( animationSpeed, function() { |
| 800 | 882 | $( this ).remove(); |
| 801 | 883 | }); |
| 802 | 884 | $( 'html' ).removeClass( 'busy' ); |
| @@ -808,9 +890,8 @@ | ||
| 808 | 890 | |
| 809 | 891 | // Enable inputs, remove spinner. |
| 810 | 892 | $caller.removeAttr( 'disabled' ); |
| 811 | 893 | $usermeta.removeAttr( 'disabled' ); |
| 812 | - $caller.css( 'display', 'none' ); | |
| 813 | 894 | $( 'form .spinner:not(:has(.spinner-text))' ).animate( { width: '60px' }, 'fast' ).append( '<span class="spinner-text">' + spinnerText + '</span>' ).delay( spinnerWait ).hide( animationSpeed, function() { |
| 814 | 895 | $( this ).remove(); |
| 815 | 896 | }); |
| 816 | 897 | $( 'html' ).removeClass( 'busy' ); |
| @@ -923,13 +1004,12 @@ | ||
| 923 | 1004 | }) |
| 924 | 1005 | ); |
| 925 | 1006 | |
| 926 | 1007 | // 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 = ' <a title="' + authL10n.local_wordpress_user + '" class="auth-local-user' + ( shouldCreateLocalAccount ? '' : ' invisible' ) + '"><span class="glyphicon glyphicon-user"></span></a>'; | |
| 931 | - var multisiteIcon = ' <a title="WordPress Multisite user" class="auth-multisite-user'+ ( isMultisite ? '' : ' invisible' ) + '"><span class="glyphicon glyphicon-globe"></span></a>'; | |
| 1008 | + var authJsPrefix = isMultisite ? 'authMultisite' : 'auth'; | |
| 1009 | + var multisiteIcon = isMultisite ? '<a title="WordPress Multisite user" class="button disabled auth-multisite-user dashicons-before dashicons-admin-site"></a>' : ''; | |
| 1010 | + 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>'; | |
| 1011 | + var ignoreButton = '<a class="button dashicons-before dashicons-no" id="ignore_user_' + nextId + '" onclick="' + authJsPrefix + 'IgnoreUser( this, \'' + list + '\' );" title="' + authL10n.remove_user + '"></a>'; | |
| 932 | 1012 | $( ' \ |
| 933 | 1013 | <li id="new_user_' + nextId + '" class="new-user" style="display: none;"> \ |
| 934 | 1014 | <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 | 1015 | <select name="auth_settings[access_users_' + list + '][' + nextId + '][role]" class="auth-role" onchange="' + authJsPrefix + 'ChangeRole( this );"> \ |
| @@ -934,9 +1014,9 @@ | ||
| 934 | 1014 | <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 | 1015 | <select name="auth_settings[access_users_' + list + '][' + nextId + '][role]" class="auth-role" onchange="' + authJsPrefix + 'ChangeRole( this );"> \ |
| 936 | 1016 | </select> \ |
| 937 | 1017 | <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 + ' \ | |
| 1018 | + ' + multisiteIcon + banButton + ignoreButton + ' \ | |
| 939 | 1019 | <span class="spinner is-active"></span> \ |
| 940 | 1020 | </li> \ |
| 941 | 1021 | ' ).appendTo( '#list_auth_settings_access_users_' + list ).slideDown( 250 ); |
| 942 | 1022 | |
| @@ -1061,8 +1141,19 @@ | ||
| 1061 | 1141 | }); |
| 1062 | 1142 | |
| 1063 | 1143 | var access_default_role = $( '#auth_settings_access_default_role' ).val(); |
| 1064 | 1144 | |
| 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(); | |
| 1155 | + | |
| 1065 | 1156 | var google = $( '#auth_settings_google' ).is( ':checked' ) ? '1' : ''; |
| 1066 | 1157 | var google_clientid = $( '#auth_settings_google_clientid' ).val(); |
| 1067 | 1158 | var google_clientsecret = $( '#auth_settings_google_clientsecret' ).val(); |
| 1068 | 1159 | var google_hosteddomain = $( '#auth_settings_google_hosteddomain' ).val(); |
| @@ -1075,9 +1166,9 @@ | ||
| 1075 | 1166 | var cas_version = $( '#auth_settings_cas_version' ).val(); |
| 1076 | 1167 | var cas_attr_email = $( '#auth_settings_cas_attr_email' ).val(); |
| 1077 | 1168 | var cas_attr_first_name = $( '#auth_settings_cas_attr_first_name' ).val(); |
| 1078 | 1169 | 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' : ''; | |
| 1170 | + var cas_attr_update_on_login = $( '#auth_settings_cas_attr_update_on_login' ).val(); | |
| 1080 | 1171 | var cas_auto_login = $( '#auth_settings_cas_auto_login' ).is( ':checked' ) ? '1' : ''; |
| 1081 | 1172 | var cas_link_on_username = $( '#auth_settings_cas_link_on_username' ).is( ':checked' ) ? '1' : ''; |
| 1082 | 1173 | |
| 1083 | 1174 | var ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : ''; |
| @@ -1083,8 +1174,9 @@ | ||
| 1083 | 1174 | var ldap = $( '#auth_settings_ldap' ).is( ':checked' ) ? '1' : ''; |
| 1084 | 1175 | var ldap_host = $( '#auth_settings_ldap_host' ).val(); |
| 1085 | 1176 | var ldap_port = $( '#auth_settings_ldap_port' ).val(); |
| 1086 | 1177 | var ldap_search_base = $( '#auth_settings_ldap_search_base' ).val(); |
| 1178 | + var ldap_search_filter = $( '#auth_settings_ldap_search_filter' ).val(); | |
| 1087 | 1179 | var ldap_uid = $( '#auth_settings_ldap_uid' ).val(); |
| 1088 | 1180 | var ldap_attr_email = $( '#auth_settings_ldap_attr_email' ).val(); |
| 1089 | 1181 | var ldap_user = $( '#auth_settings_ldap_user' ).val(); |
| 1090 | 1182 | var ldap_password = $( '#auth_settings_ldap_password' ).val(); |
| @@ -1091,9 +1183,10 @@ | ||
| 1091 | 1183 | var ldap_tls = $( '#auth_settings_ldap_tls' ).is( ':checked' ) ? '1' : ''; |
| 1092 | 1184 | var ldap_lostpassword_url = $( '#auth_settings_ldap_lostpassword_url' ).val(); |
| 1093 | 1185 | var ldap_attr_first_name = $( '#auth_settings_ldap_attr_first_name' ).val(); |
| 1094 | 1186 | 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' : ''; | |
| 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(); | |
| 1096 | 1189 | |
| 1097 | 1190 | var advanced_lockouts = { |
| 1098 | 1191 | attempts_1: $( '#auth_settings_advanced_lockouts_attempts_1' ).val(), |
| 1099 | 1192 | duration_1: $( '#auth_settings_advanced_lockouts_duration_1' ).val(), |
| @@ -1101,8 +1194,9 @@ | ||
| 1101 | 1194 | duration_2: $( '#auth_settings_advanced_lockouts_duration_2' ).val(), |
| 1102 | 1195 | reset_duration: $( '#auth_settings_advanced_lockouts_reset_duration' ).val(), |
| 1103 | 1196 | }; |
| 1104 | 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' : ''; | |
| 1105 | 1199 | var advanced_widget_enabled = $( '#auth_settings_advanced_widget_enabled' ).is( ':checked' ) ? '1' : ''; |
| 1106 | 1200 | var advanced_users_per_page = $( '#auth_settings_advanced_users_per_page' ).val(); |
| 1107 | 1201 | var advanced_users_sort_by = $( '#auth_settings_advanced_users_sort_by' ).val(); |
| 1108 | 1202 | var advanced_users_sort_order = $( '#auth_settings_advanced_users_sort_order' ).val(); |
| @@ -1114,8 +1208,18 @@ | ||
| 1114 | 1208 | access_who_can_login: access_who_can_login, |
| 1115 | 1209 | access_who_can_view: access_who_can_view, |
| 1116 | 1210 | access_users_approved: access_users_approved, |
| 1117 | 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, | |
| 1118 | 1222 | google: google, |
| 1119 | 1223 | google_clientid: google_clientid, |
| 1120 | 1224 | google_clientsecret: google_clientsecret, |
| 1121 | 1225 | google_hosteddomain: google_hosteddomain, |
| @@ -1134,8 +1238,9 @@ | ||
| 1134 | 1238 | ldap: ldap, |
| 1135 | 1239 | ldap_host: ldap_host, |
| 1136 | 1240 | ldap_port: ldap_port, |
| 1137 | 1241 | ldap_search_base: ldap_search_base, |
| 1242 | + ldap_search_filter: ldap_search_filter, | |
| 1138 | 1243 | ldap_uid: ldap_uid, |
| 1139 | 1244 | ldap_attr_email: ldap_attr_email, |
| 1140 | 1245 | ldap_user: ldap_user, |
| 1141 | 1246 | ldap_password: ldap_password, |
| @@ -1143,10 +1248,12 @@ | ||
| 1143 | 1248 | ldap_lostpassword_url: ldap_lostpassword_url, |
| 1144 | 1249 | ldap_attr_first_name: ldap_attr_first_name, |
| 1145 | 1250 | ldap_attr_last_name: ldap_attr_last_name, |
| 1146 | 1251 | ldap_attr_update_on_login: ldap_attr_update_on_login, |
| 1252 | + ldap_test_user: ldap_test_user, | |
| 1147 | 1253 | advanced_lockouts: advanced_lockouts, |
| 1148 | 1254 | advanced_hide_wp_login: advanced_hide_wp_login, |
| 1255 | + advanced_disable_wp_login: advanced_disable_wp_login, | |
| 1149 | 1256 | advanced_users_per_page: advanced_users_per_page, |
| 1150 | 1257 | advanced_users_sort_by: advanced_users_sort_by, |
| 1151 | 1258 | advanced_users_sort_order: advanced_users_sort_order, |
| 1152 | 1259 | advanced_widget_enabled: advanced_widget_enabled, |