diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js
index ec76df9c7f..862f6e123f 100644
|
a
|
b
|
|
| 5 | 5 | /* global ajaxurl, pwsL10n, userProfileL10n */ |
| 6 | 6 | (function($) { |
| 7 | 7 | var updateLock = false, |
| 8 | | |
| 9 | 8 | $pass1Row, |
| 10 | 9 | $pass1Wrap, |
| 11 | 10 | $pass1, |
| … |
… |
|
| 17 | 16 | $toggleButton, |
| 18 | 17 | $submitButtons, |
| 19 | 18 | $submitButton, |
| 20 | | currentPass; |
| | 19 | currentPass, |
| | 20 | $passwordWrapper; |
| 21 | 21 | |
| 22 | 22 | function generatePassword() { |
| 23 | 23 | if ( typeof zxcvbn !== 'function' ) { |
| 24 | 24 | setTimeout( generatePassword, 50 ); |
| 25 | 25 | return; |
| 26 | | } else if ( ! $pass1.val() ) { |
| | 26 | } else if ( ! $pass1.val() || $passwordWrapper.hasClass( 'is-open' ) ) { |
| 27 | 27 | // zxcvbn loaded before user entered password. |
| 28 | 28 | $pass1.val( $pass1.data( 'pw' ) ); |
| 29 | 29 | $pass1.trigger( 'pwupdate' ); |
| 30 | 30 | showOrHideWeakPasswordCheckbox(); |
| 31 | | } |
| 32 | | else { |
| | 31 | } else { |
| 33 | 32 | // zxcvbn loaded after the user entered password, check strength. |
| 34 | 33 | check_pass_strength(); |
| 35 | 34 | showOrHideWeakPasswordCheckbox(); |
| 36 | 35 | } |
| 37 | 36 | |
| | 37 | // Install screen. |
| 38 | 38 | if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { |
| | 39 | // Show the password not masked if admin_password hasn't been posted yet. |
| 39 | 40 | $pass1Wrap.addClass( 'show-password' ); |
| 40 | 41 | } else { |
| | 42 | // Otherwise, mask the password. |
| 41 | 43 | $toggleButton.trigger( 'click' ); |
| 42 | 44 | } |
| 43 | 45 | |
| … |
… |
|
| 101 | 103 | .removeClass( 'dashicons-visibility' ) |
| 102 | 104 | .addClass( 'dashicons-hidden' ); |
| 103 | 105 | |
| 104 | | $pass1Text.focus(); |
| 105 | | |
| 106 | 106 | $pass1Label.attr( 'for', 'pass1-text' ); |
| 107 | 107 | } |
| 108 | 108 | |
| … |
… |
|
| 113 | 113 | $pass1Wrap.addClass( 'show-password' ); |
| 114 | 114 | |
| 115 | 115 | resetToggle(); |
| 116 | | |
| 117 | | if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) { |
| 118 | | $pass1Text[0].setSelectionRange( 0, 100 ); |
| 119 | | } |
| 120 | 116 | } else { |
| 121 | 117 | $pass1Wrap.removeClass( 'show-password' ); |
| 122 | 118 | $toggleButton |
| … |
… |
|
| 131 | 127 | .removeClass('dashicons-hidden') |
| 132 | 128 | .addClass('dashicons-visibility'); |
| 133 | 129 | |
| 134 | | $pass1.focus(); |
| 135 | | |
| 136 | 130 | $pass1Label.attr( 'for', 'pass1' ); |
| 137 | | |
| 138 | | if ( ! _.isUndefined( $pass1[0].setSelectionRange ) ) { |
| 139 | | $pass1[0].setSelectionRange( 0, 100 ); |
| 140 | | } |
| 141 | 131 | } |
| 142 | 132 | }); |
| 143 | 133 | } |
| 144 | 134 | |
| 145 | 135 | function bindPasswordForm() { |
| 146 | | var $passwordWrapper, |
| 147 | | $generateButton, |
| | 136 | var $generateButton, |
| 148 | 137 | $cancelButton; |
| 149 | 138 | |
| 150 | 139 | $pass1Row = $('.user-pass1-wrap'); |
| 151 | | $pass1Label = $pass1Row.find('th label').attr( 'for', 'pass1-text' ); |
| | 140 | $pass1Label = $pass1Row.find( '.user-pass1-label' ).attr( 'for', 'pass1-text' ); |
| 152 | 141 | |
| 153 | | // hide this |
| | 142 | // Hide the Repeat Password field. |
| 154 | 143 | $('.user-pass2-wrap').hide(); |
| 155 | 144 | |
| 156 | 145 | $submitButton = $( '#submit, #wp-submit' ).on( 'click', function () { |
| … |
… |
|
| 170 | 159 | bindPass1(); |
| 171 | 160 | } |
| 172 | 161 | |
| 173 | | /** |
| | 162 | /* |
| 174 | 163 | * Fix a LastPass mismatch issue, LastPass only changes pass2. |
| 175 | 164 | * |
| 176 | 165 | * This fixes the issue by copying any changes from the hidden |
| … |
… |
|
| 197 | 186 | |
| 198 | 187 | bindToggleButton(); |
| 199 | 188 | |
| 200 | | if ( $generateButton.length ) { |
| 201 | | $passwordWrapper.hide(); |
| 202 | | } |
| 203 | | |
| 204 | | $generateButton.show(); |
| 205 | 189 | $generateButton.on( 'click', function () { |
| 206 | 190 | updateLock = true; |
| 207 | 191 | |
| 208 | | $generateButton.hide(); |
| 209 | | $passwordWrapper.show(); |
| | 192 | $generateButton.attr( 'aria-expanded', 'true' ); |
| | 193 | |
| | 194 | $passwordWrapper |
| | 195 | .show() |
| | 196 | .addClass( 'is-open' ); |
| 210 | 197 | |
| 211 | 198 | // Enable the inputs when showing. |
| 212 | 199 | $pass1.attr( 'disabled', false ); |
| 213 | 200 | $pass2.attr( 'disabled', false ); |
| 214 | 201 | $pass1Text.attr( 'disabled', false ); |
| 215 | 202 | |
| 216 | | if ( $pass1Text.val().length === 0 ) { |
| 217 | | generatePassword(); |
| 218 | | } |
| 219 | | |
| 220 | | _.defer( function() { |
| 221 | | $pass1Text.focus(); |
| 222 | | if ( ! _.isUndefined( $pass1Text[0].setSelectionRange ) ) { |
| 223 | | $pass1Text[0].setSelectionRange( 0, 100 ); |
| 224 | | } |
| 225 | | }, 0 ); |
| 226 | | } ); |
| 227 | | |
| 228 | | $cancelButton = $pass1Row.find( 'button.wp-cancel-pw' ); |
| 229 | | $cancelButton.on( 'click', function () { |
| 230 | | updateLock = false; |
| 231 | | |
| 232 | | // Clear any entered password. |
| 233 | | $pass1Text.val( '' ); |
| 234 | | |
| | 203 | // Always generate a password when clicking the button. |
| 235 | 204 | // Generate a new password. |
| 236 | 205 | wp.ajax.post( 'generate-password' ) |
| 237 | 206 | .done( function( data ) { |
| 238 | 207 | $pass1.data( 'pw', data ); |
| | 208 | generatePassword(); |
| | 209 | resetToggle(); |
| 239 | 210 | } ); |
| | 211 | } ); |
| 240 | 212 | |
| 241 | | $generateButton.show(); |
| 242 | | $passwordWrapper.hide(); |
| 243 | | |
| 244 | | $weakRow.hide( 0, function () { |
| 245 | | $weakCheckbox.removeProp( 'checked' ); |
| 246 | | } ); |
| 247 | | |
| 248 | | // Disable the inputs when hiding to prevent autofill and submission. |
| 249 | | $pass1.prop( 'disabled', true ); |
| 250 | | $pass2.prop( 'disabled', true ); |
| 251 | | $pass1Text.prop( 'disabled', true ); |
| 252 | | |
| 253 | | resetToggle(); |
| | 213 | $cancelButton = $pass1Row.find( 'button.wp-cancel-pw' ); |
| | 214 | $cancelButton.on( 'click', function () { |
| | 215 | updateLock = false; |
| 254 | 216 | |
| 255 | | if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) { |
| 256 | | // Clear password field to prevent update |
| 257 | | $pass1.val( '' ).trigger( 'pwupdate' ); |
| 258 | | $submitButtons.prop( 'disabled', false ); |
| 259 | | } |
| | 217 | // Clear password field to prevent update. |
| | 218 | $pass1Text.val( '' ); |
| | 219 | $pass1.val( '' ).trigger( 'pwupdate' ); |
| 260 | 220 | } ); |
| 261 | 221 | |
| 262 | 222 | $pass1Row.closest( 'form' ).on( 'submit', function () { |
| … |
… |
|
| 365 | 325 | }); |
| 366 | 326 | }); |
| 367 | 327 | |
| 368 | | /** |
| 369 | | * Replaces "Howdy, *" in the admin toolbar whenever the display name dropdown is updated for one's own profile. |
| | 328 | /* |
| | 329 | * Replaces "Howdy, *" in the admin toolbar whenever the display name |
| | 330 | * dropdown is updated for one's own profile. |
| 370 | 331 | */ |
| 371 | 332 | select.on( 'change', function() { |
| 372 | 333 | if ( user_id !== current_user_id ) { |
| … |
… |
|
| 452 | 413 | |
| 453 | 414 | window.generatePassword = generatePassword; |
| 454 | 415 | |
| 455 | | /* Warn the user if password was generated but not saved */ |
| | 416 | // Warn the user if password was generated but not saved. |
| 456 | 417 | $( window ).on( 'beforeunload', function () { |
| 457 | 418 | if ( true === updateLock ) { |
| 458 | 419 | return userProfileL10n.warn; |
diff --git a/src/wp-admin/css/forms.css b/src/wp-admin/css/forms.css
index 3013434604..74fdd57c89 100644
|
a
|
b
|
fieldset label, |
| 455 | 455 | vertical-align: baseline; |
| 456 | 456 | } |
| 457 | 457 | |
| | 458 | .wp-generate-pw + .wp-pwd { |
| | 459 | margin-top: 1em; |
| | 460 | } |
| | 461 | |
| 458 | 462 | #pass-strength-result { |
| 459 | 463 | background-color: #eee; |
| 460 | 464 | border: 1px solid #ddd; |
diff --git a/src/wp-admin/css/login.css b/src/wp-admin/css/login.css
index 686be7dde9..ff6f47cf07 100644
|
a
|
b
|
p { |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | .login .password-input-wrapper { |
| 82 | | display: table; |
| | 82 | display: table; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | .login .input.password-input { |
| 86 | | display: table-cell; |
| 87 | | margin: 0; |
| | 86 | display: table-cell; |
| | 87 | margin: 0; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | .login .pw-weak { |
| 91 | | margin-bottom: 15px; |
| | 91 | margin-bottom: 15px; |
| | 92 | } |
| | 93 | |
| | 94 | .login .wp-hide-pw-wrapper { |
| | 95 | display: table-cell; |
| | 96 | vertical-align: top; |
| 92 | 97 | } |
| 93 | 98 | |
| 94 | 99 | .login .button.button-secondary { |
| 95 | | display: table-cell; |
| 96 | | border-radius: 0; |
| 97 | | vertical-align: middle; |
| | 100 | height: 36px; |
| | 101 | margin: 0; |
| | 102 | border-radius: 0; |
| | 103 | line-height: normal; |
| | 104 | } |
| | 105 | |
| | 106 | .login .wp-hide-pw .dashicons { |
| | 107 | position: static; |
| 98 | 108 | } |
| 99 | 109 | |
| 100 | 110 | .login form { |
diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php
index 4ee27d6100..42c4d9e6d0 100644
|
a
|
b
|
function display_setup_form( $error = null ) { |
| 137 | 137 | <?php if ( ! $user_table ) : ?> |
| 138 | 138 | <tr class="form-field form-required user-pass1-wrap"> |
| 139 | 139 | <th scope="row"> |
| 140 | | <label for="pass1"> |
| | 140 | <label for="pass1" class="user-pass1-label"> |
| 141 | 141 | <?php _e( 'Password' ); ?> |
| 142 | 142 | </label> |
| 143 | 143 | </th> |
diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php
index 521a8e290d..ba58f52d46 100644
|
a
|
b
|
endif; //!IS_PROFILE_PAGE |
| 610 | 610 | <h2><?php _e( 'Account Management' ); ?></h2> |
| 611 | 611 | <table class="form-table"> |
| 612 | 612 | <tr id="password" class="user-pass1-wrap"> |
| 613 | | <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th> |
| | 613 | <th><label for="pass1" class="user-pass1-label"><?php _e( 'New Password' ); ?></label></th> |
| 614 | 614 | <td> |
| 615 | 615 | <input class="hidden" value=" " /><!-- #24364 workaround --> |
| 616 | | <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button> |
| | 616 | <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button> |
| 617 | 617 | <div class="wp-pwd hide-if-js"> |
| 618 | 618 | <span class="password-input-wrapper"> |
| 619 | 619 | <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" /> |
| … |
… |
endif; //!IS_PROFILE_PAGE |
| 622 | 622 | <span class="dashicons dashicons-hidden"></span> |
| 623 | 623 | <span class="text"><?php _e( 'Hide' ); ?></span> |
| 624 | 624 | </button> |
| 625 | | <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> |
| | 625 | <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel' ); ?>"> |
| 626 | 626 | <span class="text"><?php _e( 'Cancel' ); ?></span> |
| 627 | 627 | </button> |
| 628 | 628 | <div style="display:none" id="pass-strength-result" aria-live="polite"></div> |
| … |
… |
endif; //!IS_PROFILE_PAGE |
| 632 | 632 | <tr class="user-pass2-wrap hide-if-js"> |
| 633 | 633 | <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th> |
| 634 | 634 | <td> |
| 635 | | <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" /> |
| 636 | | <p class="description"><?php _e( 'Type your new password again.' ); ?></p> |
| | 635 | <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" aria-describedby="pass2-desc" /> |
| | 636 | <?php if ( IS_PROFILE_PAGE ) : ?> |
| | 637 | <p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p> |
| | 638 | <?php else : ?> |
| | 639 | <p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p> |
| | 640 | <?php endif; ?> |
| 637 | 641 | </td> |
| 638 | 642 | </tr> |
| 639 | 643 | <tr class="pw-weak"> |
| … |
… |
endif; //!IS_PROFILE_PAGE |
| 641 | 645 | <td> |
| 642 | 646 | <label> |
| 643 | 647 | <input type="checkbox" name="pw_weak" class="pw-checkbox" /> |
| 644 | | <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span> |
| | 648 | <span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span> |
| 645 | 649 | </label> |
| 646 | 650 | </td> |
| 647 | 651 | </tr> |
diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php
index 48387b0373..3be147c0e5 100644
|
a
|
b
|
if ( current_user_can( 'create_users' ) ) { |
| 490 | 490 | </tr> |
| 491 | 491 | <tr class="form-field form-required user-pass1-wrap"> |
| 492 | 492 | <th scope="row"> |
| 493 | | <label for="pass1"> |
| | 493 | <label for="pass1" class="user-pass1-label"> |
| 494 | 494 | <?php _e( 'Password' ); ?> |
| 495 | 495 | <span class="description hide-if-js"><?php _e( '(required)' ); ?></span> |
| 496 | 496 | </label> |
| 497 | 497 | </th> |
| 498 | 498 | <td> |
| 499 | 499 | <input class="hidden" value=" " /><!-- #24364 workaround --> |
| 500 | | <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Show password' ); ?></button> |
| | 500 | <button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button> |
| 501 | 501 | <div class="wp-pwd hide-if-js"> |
| 502 | 502 | <?php $initial_password = wp_generate_password( 24 ); ?> |
| 503 | 503 | <span class="password-input-wrapper"> |
| … |
… |
if ( current_user_can( 'create_users' ) ) { |
| 507 | 507 | <span class="dashicons dashicons-hidden"></span> |
| 508 | 508 | <span class="text"><?php _e( 'Hide' ); ?></span> |
| 509 | 509 | </button> |
| 510 | | <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>"> |
| | 510 | <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel' ); ?>"> |
| 511 | 511 | <span class="text"><?php _e( 'Cancel' ); ?></span> |
| 512 | 512 | </button> |
| 513 | 513 | <div style="display:none" id="pass-strength-result" aria-live="polite"></div> |
| … |
… |
if ( current_user_can( 'create_users' ) ) { |
| 517 | 517 | <tr class="form-field form-required user-pass2-wrap hide-if-js"> |
| 518 | 518 | <th scope="row"><label for="pass2"><?php _e( 'Repeat Password' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> |
| 519 | 519 | <td> |
| 520 | | <input name="pass2" type="password" id="pass2" autocomplete="off" /> |
| | 520 | <input name="pass2" type="password" id="pass2" autocomplete="off" aria-describedby="pass2-desc" /> |
| | 521 | <p class="description" id="pass2-desc"><?php _e( 'Type the password again.' ); ?></p> |
| 521 | 522 | </td> |
| 522 | 523 | </tr> |
| 523 | 524 | <tr class="pw-weak"> |
diff --git a/src/wp-login.php b/src/wp-login.php
index 1a302a35f1..06876d788d 100644
|
a
|
b
|
switch ( $action ) { |
| 706 | 706 | |
| 707 | 707 | <div class="user-pass1-wrap"> |
| 708 | 708 | <p> |
| 709 | | <label for="pass1"><?php _e( 'New password' ); ?></label> |
| | 709 | <label for="pass1" class="user-pass1-label"><?php _e( 'New password' ); ?></label> |
| 710 | 710 | </p> |
| 711 | 711 | |
| 712 | | <div class="wp-pwd"> |
| | 712 | <div class="login-wp-pwd"> |
| 713 | 713 | <div class="password-input-wrapper"> |
| 714 | 714 | <input type="password" data-reveal="1" data-pw="<?php echo esc_attr( wp_generate_password( 16 ) ); ?>" name="pass1" id="pass1" class="input password-input" size="24" value="" autocomplete="off" aria-describedby="pass-strength-result" /> |
| 715 | | <span class="button button-secondary wp-hide-pw hide-if-no-js"> |
| 716 | | <span class="dashicons dashicons-hidden"></span> |
| 717 | | </span> |
| | 715 | <span class="wp-hide-pw-wrapper"> |
| | 716 | <button type="button" class="button button-secondary wp-hide-pw hide-if-no-js"> |
| | 717 | <span class="dashicons dashicons-hidden"></span> |
| | 718 | </button> |
| | 719 | </span> |
| 718 | 720 | </div> |
| 719 | 721 | <div id="pass-strength-result" class="hide-if-no-js" aria-live="polite"><?php _e( 'Strength indicator' ); ?></div> |
| 720 | 722 | </div> |