Changeset 37940
- Timestamp:
- 07/01/2016 12:44:43 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/password-strength-meter.js
r37431 r37940 18 18 if (password1 != password2 && password2 && password2.length > 0) 19 19 return 5; 20 21 if ( 'undefined' === typeof window.zxcvbn ) { 22 // Password strength unknown. 23 return -1; 24 } 20 25 21 26 var result = zxcvbn( password1, blacklist ); -
trunk/src/wp-admin/js/user-profile.js
r35870 r37940 31 31 if ( typeof zxcvbn !== 'function' ) { 32 32 setTimeout( generatePassword, 50 ); 33 return; 34 } else if ( ! $pass1.val() ) { 35 // zxcvbn loaded before user entered password. 36 $pass1.val( $pass1.data( 'pw' ) ); 37 $pass1.trigger( 'pwupdate' ); 38 showOrHideWeakPasswordCheckbox(); 39 } 40 else { 41 // zxcvbn loaded after the user entered password, check strength. 42 check_pass_strength(); 43 showOrHideWeakPasswordCheckbox(); 44 } 45 46 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { 47 $pass1Wrap.addClass( 'show-password' ); 33 48 } else { 34 $pass1.val( $pass1.data( 'pw' ) ); 35 $pass1.trigger( 'pwupdate' ).trigger( 'wp-check-valid-field' ); 36 if ( 1 !== parseInt( $toggleButton.data( 'start-masked' ), 10 ) ) { 37 $pass1Wrap.addClass( 'show-password' ); 38 } else { 39 $toggleButton.trigger( 'click' ); 40 } 41 } 49 $toggleButton.trigger( 'click' ); 50 } 51 52 // Once zxcvbn loads, passwords strength is known. 53 $( '#pw-weak-text-label' ).html( userProfileL10n.warnWeak ); 42 54 } 43 55 44 56 function bindPass1() { 45 var passStrength = $('#pass-strength-result')[0];46 47 57 currentPass = $pass1.val(); 48 58 … … 83 93 } 84 94 $pass1.add( $pass1Text ).removeClass( 'short bad good strong' ); 85 86 if ( passStrength.className ) { 87 $pass1.add( $pass1Text ).addClass( passStrength.className ); 88 if ( 'short' === passStrength.className || 'bad' === passStrength.className ) { 89 if ( ! $weakCheckbox.prop( 'checked' ) ) { 90 $submitButtons.prop( 'disabled', true ); 91 } 92 $weakRow.show(); 93 } else { 94 $submitButtons.prop( 'disabled', false ); 95 $weakRow.hide(); 96 } 97 } 95 showOrHideWeakPasswordCheckbox(); 98 96 } ); 99 97 } … … 290 288 291 289 switch ( strength ) { 290 case -1: 291 $( '#pass-strength-result' ).addClass( 'bad' ).html( pwsL10n.unknown ); 292 break; 292 293 case 2: 293 294 $('#pass-strength-result').addClass('bad').html( pwsL10n.bad ); … … 307 308 } 308 309 310 function showOrHideWeakPasswordCheckbox() { 311 var passStrength = $('#pass-strength-result')[0]; 312 313 if ( passStrength.className ) { 314 $pass1.add( $pass1Text ).addClass( passStrength.className ); 315 if ( 'short' === passStrength.className || 'bad' === passStrength.className ) { 316 if ( ! $weakCheckbox.prop( 'checked' ) ) { 317 $submitButtons.prop( 'disabled', true ); 318 } 319 $weakRow.show(); 320 } else { 321 $submitButtons.prop( 'disabled', false ); 322 $weakRow.hide(); 323 } 324 } 325 } 326 309 327 $(document).ready( function() { 310 328 var $colorpicker, $stylesheet, user_id, current_user_id, -
trunk/src/wp-admin/user-edit.php
r37914 r37940 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> -
trunk/src/wp-includes/script-loader.php
r37914 r37940 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' ), … … 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' ),
Note: See TracChangeset
for help on using the changeset viewer.