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.module b/core/modules/user/user.module index 8d73b82..2d6fc2d 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -2756,35 +2756,38 @@ function _user_mail_notify($op, $account, $langcode = NULL) { * @see system_element_info() */ function user_form_process_password_confirm($element) { - global $user; - - $js_settings = array( - 'password' => array( - 'strengthTitle' => t('Password strength:'), - 'hasWeaknesses' => t('To make your password stronger:'), - 'tooShort' => t('Make it at least 6 characters'), - 'addLowerCase' => t('Add lowercase letters'), - 'addUpperCase' => t('Add uppercase letters'), - '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 : ''), - ), - ); + if (config('user.settings')->get('password_strength')) { + + global $user; + + $js_settings = array( + 'password' => array( + 'strengthTitle' => t('Password strength:'), + 'hasWeaknesses' => t('To make your password stronger:'), + 'tooShort' => t('Make it at least 6 characters'), + 'addLowerCase' => t('Add lowercase letters'), + 'addUpperCase' => t('Add uppercase letters'), + '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 : ''), + ), + ); - $element['#attached']['library'][] = array('user', 'drupal.user'); - // Ensure settings are only added once per page. - static $already_added = FALSE; - if (!$already_added) { - $already_added = TRUE; - $element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting'); + $element['#attached']['library'][] = array('user', 'drupal.user'); + // Ensure settings are only added once per page. + static $already_added = FALSE; + if (!$already_added) { + $already_added = TRUE; + $element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting'); + } } return $element;