Make WordPress Core

Ticket #32886: no-timeout.7.diff

File no-timeout.7.diff, 2.7 KB (added by adamsilverstein, 9 years ago)

fix lastpass issues

  • src/wp-admin/js/user-profile.js

     
    1313                $weakCheckbox,
    1414
    1515                $submitButtons,
    16                 $submitButton;
     16                $submitButton,
     17                currentPass;
    1718
    1819        function generatePassword() {
    1920                if ( typeof zxcvbn !== 'function' ) {
    20                    setTimeout( generatePassword, 50 );
     21                        setTimeout( generatePassword, 50 );
    2122                } else {
    22                    $pass1.val( $pass1.data( 'pw' ) );
    23                    $pass1.trigger( 'propertychange' );
    24                    $pass1Wrap.addClass( 'show-password' );
     23                        $pass1.val( $pass1.data( 'pw' ) );
     24                        $pass1.trigger( 'pwupdate' );
     25                        $pass1Wrap.addClass( 'show-password' );
    2526                }
    2627        }
    2728
    2829        function bindPass1() {
    2930                var passStrength = $('#pass-strength-result')[0];
    30                 var currentPass = $pass1.val();
    3131
     32                currentPass = $pass1.val();
     33
    3234                $pass1Wrap = $pass1.parent();
    3335
    3436                $pass1Text = $( '<input type="text"/>' )
     
    4042                        .addClass( $pass1[0].className )
    4143                        .data( 'pw', $pass1.data( 'pw' ) )
    4244                        .val( $pass1.val() )
    43                         .on( 'input', function () {
    44                                 $pass1.val( $pass1Text.val() ).trigger( 'propertychange' );
     45                        .on( 'input propertychange', function () {
     46                                if ( $pass1Text.val() === currentPass ) {
     47                                        return;
     48                                }
     49                                $pass2.val( $pass1Text.val() );
     50                                $pass1.val( $pass1Text.val() ).trigger( 'pwupdate' );
     51                                currentPass = $pass1Text.val();
    4552                        } );
    4653
    4754                $pass1.after( $pass1Text );
     
    5057                        generatePassword();
    5158                }
    5259
    53                 $pass1.on( 'input propertychange', function () {
     60                $pass1.on( 'input propertychange pwupdate', function () {
    5461                        if ( $pass1.val() === currentPass ) {
    5562                                return;
    5663                        }
     
    149156                 * Fix a LastPass mismatch issue, LastPass only changes pass2.
    150157                 *
    151158                 * This fixes the issue by copying any changes from the hidden
    152                  * pass2 field to the pass1 field.
     159                 * pass2 field to the pass1 field, then running check_pass_strength.
    153160                 */
    154161                $pass2 = $('#pass2').on( 'input propertychange', function () {
    155162                        if ( $pass2.val().length > 0 ) {
    156163                                $pass1.val( $pass2.val() );
    157                                 $pass1.trigger( 'propertychange' );
     164                                currentPass = '';
     165                                $pass1.trigger( 'pwupdate' );
    158166                        }
    159167                } );
    160168
     
    228236                var $colorpicker, $stylesheet, user_id, current_user_id,
    229237                        select = $( '#display_name' );
    230238
    231                 $('#pass1').val('').on( 'input propertychange', check_pass_strength );
    232                 $('#pass2').val('').on( 'input propertychange', check_pass_strength );
     239                $('#pass1').val('').on( 'input propertychange pwupdate', check_pass_strength );
    233240                $('#pass-strength-result').show();
    234241                $('.color-palette').click( function() {
    235242                        $(this).siblings('input[name="admin_color"]').prop('checked', true);