diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc
index 263add5..bd7302b 100644
--- a/core/modules/user/user.admin.inc
+++ b/core/modules/user/user.admin.inc
@@ -325,6 +325,18 @@ function user_admin_settings($form, &$form_state) {
$form['language'] += translation_entity_enable_widget('user', 'user', $form, $form_state);
}
+ $form['pass_strength'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Pass strength check'),
+ );
+
+ $form['pass_strength']['user_password_strength'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Enable password strength check'),
+ '#default_value' => $config->get('password_strength'),
+ '#description' => t('Enable password strength checking during account creation and modification.')
+ );
+
// User registration settings.
$form['registration_cancellation'] = array(
'#type' => 'details',
@@ -610,6 +622,7 @@ function user_admin_settings_submit($form, &$form_state) {
->set('anonymous', $form_state['values']['anonymous'])
->set('admin_role', $form_state['values']['user_admin_role'])
->set('register', $form_state['values']['user_register'])
+ ->set('password_strength', $form_state['values']['user_password_strength'])
->set('verify_mail', $form_state['values']['user_email_verification'])
->set('signatures', $form_state['values']['user_signatures'])
->set('cancel_method', $form_state['values']['user_cancel_method'])
diff --git a/core/modules/user/user.js b/core/modules/user/user.js
index 8e0e135..12d7271 100644
--- a/core/modules/user/user.js
+++ b/core/modules/user/user.js
@@ -23,38 +23,40 @@ Drupal.behaviors.password = {
var confirmResult = outerWrapper.find('div.password-confirm');
var confirmChild = confirmResult.find('span');
- // Add the description box.
- var passwordMeter = '
' + translate.strengthTitle + '
';
- confirmInput.parent().after('');
- innerWrapper.prepend(passwordMeter);
- var passwordDescription = outerWrapper.find('div.password-suggestions').hide();
-
- // Check the password strength.
- var passwordCheck = function () {
+ if (typeof settings.password.strengthTitle != 'undefined') {
+ // Add the description box.
+ var passwordMeter = '' + translate.strengthTitle + '
';
+ confirmInput.parent().after('');
+ innerWrapper.prepend(passwordMeter);
+ var passwordDescription = outerWrapper.find('div.password-suggestions').hide();
+
+ // Check the password strength.
+ var passwordCheck = function () {
+
+ // Evaluate the password strength.
+ var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password);
+
+ // Update the suggestions for how to improve the password.
+ if (passwordDescription.html() !== result.message) {
+ passwordDescription.html(result.message);
+ }
- // Evaluate the password strength.
- var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password);
+ // Only show the description box if there is a weakness in the password.
+ if (result.strength === 100) {
+ passwordDescription.hide();
+ }
+ else {
+ passwordDescription.show();
+ }
- // Update the suggestions for how to improve the password.
- if (passwordDescription.html() !== result.message) {
- passwordDescription.html(result.message);
- }
+ // Adjust the length of the strength indicator.
+ innerWrapper.find('.indicator')
+ .css('width', result.strength + '%')
+ .css('background-color', result.indicatorColor);
- // Only show the description box if there is a weakness in the password.
- if (result.strength === 100) {
- passwordDescription.hide();
+ // Update the strength indication text.
+ innerWrapper.find('.password-strength-text').html(result.indicatorText);
}
- else {
- passwordDescription.show();
- }
-
- // Adjust the length of the strength indicator.
- innerWrapper.find('.indicator')
- .css('width', result.strength + '%')
- .css('background-color', result.indicatorColor);
-
- // Update the strength indication text.
- innerWrapper.find('.password-strength-text').html(result.indicatorText);
passwordCheckMatch();
};
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 8d73b82..859c3cd 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -2756,10 +2756,17 @@ function _user_mail_notify($op, $account, $langcode = NULL) {
* @see system_element_info()
*/
function user_form_process_password_confirm($element) {
- global $user;
+ $password_settings = array(
+ 'confirmTitle' => t('Passwords match:'),
+ 'confirmSuccess' => t('yes'),
+ 'confirmFailure' => t('no'),
+ );
- $js_settings = array(
- 'password' => array(
+ if (config('user.settings')->get('password_strength')) {
+
+ global $user;
+
+ $password_settings += array(
'strengthTitle' => t('Password strength:'),
'hasWeaknesses' => t('To make your password stronger:'),
'tooShort' => t('Make it at least 6 characters'),
@@ -2768,15 +2775,16 @@ function user_form_process_password_confirm($element) {
'addNumbers' => t('Add numbers'),
'addPunctuation' => t('Add punctuation'),
'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 : ''),
- ),
+ );
+ }
+
+ $js_settings = array(
+ 'password' => $password_settings,
);
$element['#attached']['library'][] = array('user', 'drupal.user');