diff options
author | Dries Buytaert <dries@buytaert.net> | 2007-06-08 06:04:15 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2007-06-08 06:04:15 +0000 |
commit | 9e0da3dc7c39786bf6d972e07819fe2880cdeaa3 (patch) | |
tree | 5249a2a0583a554ea832cd14e187d0665e0964b0 /modules/user/user.module | |
parent | 29eb5a62847349897716c316c8e409e5209f8535 (diff) | |
download | brdo-9e0da3dc7c39786bf6d972e07819fe2880cdeaa3.tar.gz brdo-9e0da3dc7c39786bf6d972e07819fe2880cdeaa3.tar.bz2 |
- Patch #143026 by ChrisKennedy and Steven: dynamically check password strength and confirmation.
Diffstat (limited to 'modules/user/user.module')
-rw-r--r-- | modules/user/user.module | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module index 741af7e0e..1ba1c772c 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1414,6 +1414,7 @@ function user_register_submit($form, &$form_state) { } function user_edit_form(&$form_state, $uid, $edit, $register = FALSE) { + _user_password_dynamic_validation(); $admin = user_access('administer users'); // Account information: @@ -3151,3 +3152,37 @@ function _user_mail_notify($op, $account, $password = NULL) { } return $result; } + +/** + * Add javascript and string translations for dynamic password validation (strength and confirmation checking). + * + * This is an internal function that makes it easier to manage the translation + * strings that need to be passed to the javascript code. + */ +function _user_password_dynamic_validation() { + static $complete = FALSE; + global $user; + // Only need to do once per page. + if (!$complete) { + drupal_add_js(drupal_get_path('module', 'user') .'/user.js', 'module'); + + drupal_add_js(array( + 'password' => array( + 'strengthTitle' => t('Password strength:'), + 'lowStrength' => t('Low'), + 'mediumStrength' => t('Medium'), + 'highStrength' => t('High'), + 'tooShort' => t('It is recommended to choose a password that contains at least six characters. It should include numbers, punctuation, and both upper and lowercase letters.'), + 'needsMoreVariation' => t('The password does not include enough variation to be secure. Try:'), + 'addLetters' => t('Adding both upper and lowercase letters.'), + 'addNumbers' => t('Adding numbers.'), + 'addPunctuation' => t('Adding punctuation.'), + 'sameAsUsername' => t('It is recommended to choose a password different from the username.'), + 'confirmSuccess' => t('Yes'), + 'confirmFailure' => t('No'), + 'confirmTitle' => t('Passwords match:'), + 'username' => (isset($user->name) ? $user->name : ''))), + 'setting'); + $complete = TRUE; + } +} |