Ticket #34905: 34905.5.diff
File 34905.5.diff, 5.0 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/password-strength-meter.js
18 18 if (password1 != password2 && password2 && password2.length > 0) 19 19 return 5; 20 20 21 if ( 'undefined' === typeof window.zxcvbn ) { 22 23 // Password strength unknown. 24 return -1; 25 } 26 21 27 var result = zxcvbn( password1, blacklist ); 22 28 return result.score; 23 29 }, -
src/wp-admin/js/user-profile.js
30 30 function generatePassword() { 31 31 if ( typeof zxcvbn !== 'function' ) { 32 32 setTimeout( generatePassword, 50 ); 33 } else { 33 return; 34 } else if ( ! $pass1.val() ) { 34 35 36 // zxcvbn loaded before user entered password. 35 37 $pass1.val( $pass1.data( 'pw' ) ); 36 38 $pass1.trigger( 'pwupdate' ).trigger( 'wp-check-valid-field' ); 37 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) {38 $pass1Wrap.addClass( 'show-password' );39 } else {40 $toggleButton.trigger( 'click' );41 }42 39 } 40 else { 43 41 42 // zxcvbn loaded after the user entered password, check strength. 43 check_pass_strength(); 44 showOrHideWeakPasswordCheckbox(); 45 } 46 47 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { 48 $pass1Wrap.addClass( 'show-password' ); 49 } else { 50 $toggleButton.trigger( 'click' ); 51 } 52 53 // Once zxcvbn loads, passwords strength is known. 54 $( '#pw-weak-text-label' ).html( userProfileL10n.warnWeak ); 44 55 } 45 56 46 57 function bindPass1() { 47 var passStrength = $('#pass-strength-result')[0];48 49 58 currentPass = $pass1.val(); -
src/wp-admin/user-edit.php
$pass1Wrap = $pass1.parent(); @@ -82,19 +91,7 @@ $pass1Text.val( currentPass ); } $pass1.add( $pass1Text ).removeClass( 'short bad good strong' ); - - if ( passStrength.className ) { - $pass1.add( $pass1Text ).addClass( passStrength.className ); - if ( 'short' === passStrength.className || 'bad' === passStrength.className ) { - if ( ! $weakCheckbox.prop( 'checked' ) ) { - $submitButtons.prop( 'disabled', true ); - } - $weakRow.show(); - } else { - $submitButtons.prop( 'disabled', false ); - $weakRow.hide(); - } - } + showOrHideWeakPasswordCheckbox(); } ); } @@ -289,6 +286,9 @@ strength = wp.passwordStrength.meter( pass1, wp.passwordStrength.userInputBlacklist(), pass1 ); switch ( strength ) { + case -1: + $( '#pass-strength-result' ).addClass( 'bad' ).html( pwsL10n.unknown ); + break; case 2: $('#pass-strength-result').addClass('bad').html( pwsL10n.bad ); break; @@ -306,6 +306,23 @@ } } + function showOrHideWeakPasswordCheckbox() { + var passStrength = $('#pass-strength-result')[0]; + + if ( passStrength.className ) { + $pass1.add( $pass1Text ).addClass( passStrength.className ); + if ( 'short' === passStrength.className || 'bad' === passStrength.className ) { + if ( ! $weakCheckbox.prop( 'checked' ) ) { + $submitButtons.prop( 'disabled', true ); + } + $weakRow.show(); + } else { + $submitButtons.prop( 'disabled', false ); + $weakRow.hide(); + } + } + } + $(document).ready( function() { var $colorpicker, $stylesheet, user_id, current_user_id, select = $( '#display_name' );
531 531 <td> 532 532 <label> 533 533 <input type="checkbox" name="pw_weak" class="pw-checkbox" /> 534 < ?php _e( 'Confirm use of weak password' ); ?>534 <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span> 535 535 </label> 536 536 </td> 537 537 </tr> -
src/wp-includes/script-loader.php
380 380 381 381 $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); 382 382 did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array( 383 'unknown' => _x( 'Password strength unknown', 'password strength' ), 383 384 'short' => _x( 'Very weak', 'password strength' ), 384 385 'bad' => _x( 'Weak', 'password strength' ), 385 386 'good' => _x( 'Medium', 'password strength' ), … … 390 391 $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter', 'wp-util' ), false, 1 ); 391 392 did_action( 'init' ) && $scripts->localize( 'user-profile', 'userProfileL10n', array( 392 393 'warn' => __( 'Your new password has not been saved.' ), 394 'warnWeak' => __( 'Confirm use of weak password.' ), 393 395 'show' => __( 'Show' ), 394 396 'hide' => __( 'Hide' ), 395 397 'cancel' => __( 'Cancel' ),