WordPress.org

Make WordPress Core

Changeset 25157


Ignore:
Timestamp:
08/28/2013 04:08:19 PM (6 years ago)
Author:
nacin
Message:

Use Dropbox's zxcvbn library for our password meter.

The library was added in [25156].

props duck_.
see #21737.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r25012 r25157  
    6464                    '!wp-includes/js/backbone.min.js',
    6565                    '!wp-includes/js/swfobject.js',
    66                     '!wp-includes/js/underscore.min.js'
     66                    '!wp-includes/js/underscore.min.js',
     67                    '!wp-includes/js/zxcvbn.min.js'
    6768                ]
    6869            },
  • trunk/src/wp-admin/js/password-strength-meter.js

    r21592 r25157  
    1 // Password strength meter
    21function passwordStrength(password1, username, password2) {
    3     var shortPass = 1, badPass = 2, goodPass = 3, strongPass = 4, mismatch = 5, symbolSize = 0, natLog, score;
    4 
    5     // password 1 != password 2
    6     if ( (password1 != password2) && password2.length > 0)
    7         return mismatch
    8 
    9     //password < 4
    10     if ( password1.length < 4 )
    11         return shortPass
    12 
    13     //password1 == username
    14     if ( password1.toLowerCase() == username.toLowerCase() )
    15         return badPass;
    16 
    17     if ( password1.match(/[0-9]/) )
    18         symbolSize +=10;
    19     if ( password1.match(/[a-z]/) )
    20         symbolSize +=26;
    21     if ( password1.match(/[A-Z]/) )
    22         symbolSize +=26;
    23     if ( password1.match(/[^a-zA-Z0-9]/) )
    24         symbolSize +=31;
    25 
    26     natLog = Math.log( Math.pow(symbolSize, password1.length) );
    27     score = natLog / Math.LN2;
    28 
    29     if (score < 40 )
    30         return badPass
    31 
    32     if (score < 56 )
    33         return goodPass
    34 
    35     return strongPass;
     2    if (password1 != password2 && password2.length > 0)
     3        return 5;
     4    var result = zxcvbn( password1, [ username ] );
     5    return result.score;
    366}
  • trunk/src/wp-includes/script-loader.php

    r25040 r25157  
    310310    ) );
    311311
    312     $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array('jquery'), false, 1 );
     312    $scripts->add( 'zxcvbn-async', "/wp-includes/js/zxcvbn-async$suffix.js", array(), '1.0' );
     313    did_action( 'init' ) && $scripts->localize( 'zxcvbn-async', '_zxcvbnSettings', array(
     314        'src' => includes_url( '/js/zxcvbn.min.js' ),
     315    ) );
     316
     317    $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 );
    313318    did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n', array(
    314319        'empty' => __('Strength indicator'),
  • trunk/src/wp-includes/version.php

    r25000 r25157  
    55 * @global string $wp_version
    66 */
    7 $wp_version = '3.7-alpha-25000';
     7$wp_version = '3.7-alpha-25157';
    88
    99/**
Note: See TracChangeset for help on using the changeset viewer.