From aca54cc198f64e9ef5df8bd5e75aacd1d2669c0b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 21 Sep 2009 08:52:41 +0000 Subject: Patch #331893 by mgifford, nigel, Xano, Everett Zufelt | Cliff, Bojhan, mcrittenden, webchick, Josh Waihi, alpritt, heather: improved the password checker. --- modules/user/user.js | 24 ++++++++++++++++++++---- modules/user/user.module | 4 ++++ 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'modules/user') diff --git a/modules/user/user.js b/modules/user/user.js index d382375ab..52279db67 100644 --- a/modules/user/user.js +++ b/modules/user/user.js @@ -18,10 +18,11 @@ Drupal.behaviors.password = { var passwordResult = $('span.password-result', passwordStrength); innerWrapper.addClass('password-parent'); - // Add the description box at the end. - var passwordMeter = '
' + translate.strengthTitle + '
'; + // Add the description box. + var passwordMeter = '
' + translate.strengthTitle + '
'; + $('div.description', outerWrapper).prepend('
'); - $(innerWrapper).append(passwordMeter); + $(innerWrapper).prepend(passwordMeter); var passwordDescription = $('div.password-suggestions', outerWrapper).hide(); // Add the password confirmation layer. @@ -52,6 +53,9 @@ Drupal.behaviors.password = { // Adjust the length of the strength indicator. $('#indicator').css('width', result.strength + '%'); + // Update the strength indication text. + $("#password-strength-text").html(result.indicatorText); + passwordCheckMatch(); }; @@ -155,9 +159,21 @@ Drupal.evaluatePasswordStrength = function (password, translate) { strength = 5; } + // Based on the strength, work out what text should be shown by the password strength meter. + if (strength < 60) { + indicatorText = translate.weak; + } else if (strength < 70) { + indicatorText = translate.fair; + } else if (strength < 80) { + indicatorText = translate.good; + } else if (strength < 100) { + indicatorText = translate.strong; + } + // Assemble the final message. msg = translate.hasWeaknesses + ''; - return { strength: strength, message: msg }; + return { strength: strength, message: msg, indicatorText: indicatorText } + }; /** diff --git a/modules/user/user.module b/modules/user/user.module index cf41f9d7e..a57965202 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -2877,6 +2877,10 @@ function _user_password_dynamic_validation() { 'sameAsUsername' => t('Make it different from your username'), 'confirmSuccess' => t('yes'), 'confirmFailure' => t('no'), + 'weak' => t('Weak'), + 'fair' => t('Fair'), + 'good' => t('Good'), + 'strong' => t('Strong'), 'confirmTitle' => t('Passwords match:'), 'username' => (isset($user->name) ? $user->name : ''))), 'setting'); -- cgit v1.2.3