Changeset 42528
- Timestamp:
- 01/18/2018 01:38:26 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/password-strength-meter.js
r37940 r42528 4 4 var passwordStrength; 5 5 (function($){ 6 7 /** 8 * Contains functions to determine the password strength. 9 * 10 * @since 3.7.0 11 * 12 * @namespace 13 */ 6 14 wp.passwordStrength = { 7 15 /** 8 * Determine the strength of a given password16 * Determines the strength of a given password. 9 17 * 10 * @param string password1 The password 11 * @param array blacklist An array of words that will lower the entropy of the password 12 * @param string password2 The confirmed password 18 * Compares first password to the password confirmation. 19 * 20 * @since 3.7.0 21 * 22 * @param {string} password1 The subject password. 23 * @param {Array} blacklist An array of words that will lower the entropy of 24 * the password. 25 * @param {string} password2 The password confirmation. 26 * 27 * @returns {number} The password strength score. 13 28 */ 14 29 meter : function( password1, blacklist, password2 ) { … … 29 44 30 45 /** 31 * Builds an array of data that should be penalized, because it would lower the entropy of a password if it were used46 * Builds an array of words that should be penalized. 32 47 * 33 * @return array The array of data to be blacklisted 48 * Certain words need to be penalized because it would lower the entropy of a 49 * password if they were used. The blacklist is based on user input fields such 50 * as username, first name, email etc. 51 * 52 * @since 3.7.0 53 * 54 * @returns {string[]} The array of words to be blacklisted. 34 55 */ 35 56 userInputBlacklist : function() { … … 39 60 userInputFields = [ 'user_login', 'first_name', 'last_name', 'nickname', 'display_name', 'email', 'url', 'description', 'weblog_title', 'admin_email' ]; 40 61 41 // Collect all the strings we want to blacklist 62 // Collect all the strings we want to blacklist. 42 63 rawValues.push( document.title ); 43 64 rawValues.push( document.URL ); … … 55 76 } 56 77 57 // Strip out non-alphanumeric characters and convert each word to an individual entry 78 /* 79 * Strip out non-alphanumeric characters and convert each word to an 80 * individual entry. 81 */ 58 82 rawValuesLength = rawValues.length; 59 83 for ( i = 0; i < rawValuesLength; i++ ) { … … 63 87 } 64 88 65 // Remove empty values, short words, and duplicates. Short words are likely to cause many false positives. 89 /* 90 * Remove empty values, short words and duplicates. Short words are likely to 91 * cause many false positives. 92 */ 66 93 blacklist = $.grep( blacklist, function( value, key ) { 67 94 if ( '' === value || 4 > value.length ) { … … 76 103 }; 77 104 78 // Back-compat. 105 // Backward compatibility. 106 107 /** 108 * Password strength meter function. 109 * 110 * @since 2.5.0 111 * @deprecated 3.7.0 Use wp.passwordStrength.meter instead. 112 * 113 * @global 114 * 115 * @type {wp.passwordStrength.meter} 116 */ 79 117 passwordStrength = wp.passwordStrength.meter; 80 118 })(jQuery);
Note: See TracChangeset
for help on using the changeset viewer.