function UserThemeHooks::processPasswordConfirm
Same name and namespace in other branches
- 11.x core/modules/user/src/Hook/UserThemeHooks.php \Drupal\user\Hook\UserThemeHooks::processPasswordConfirm()
Form element process handler for client-side password validation.
This #process handler is automatically invoked for 'password_confirm' form elements to add the JavaScript and string translations for dynamic password validation.
Parameters
array $element: The element being processed.
Return value
array The processed element
File
-
core/
modules/ user/ src/ Hook/ UserThemeHooks.php, line 191
Class
- UserThemeHooks
- Hook implementations for user.
Namespace
Drupal\user\HookCode
public function processPasswordConfirm(array $element) : array {
$password_settings = [
'confirmTitle' => $this->t('Passwords match:'),
'confirmSuccess' => $this->t('yes'),
'confirmFailure' => $this->t('no'),
'showStrengthIndicator' => FALSE,
];
if ($this->configFactory
->get('user.settings')
->get('password_strength')) {
$password_settings['showStrengthIndicator'] = TRUE;
$password_settings += [
'strengthTitle' => $this->t('Password strength:'),
'hasWeaknesses' => $this->t('Recommendations to make your password stronger:'),
'tooShort' => $this->t('Make it at least 12 characters'),
'addLowerCase' => $this->t('Add lowercase letters'),
'addUpperCase' => $this->t('Add uppercase letters'),
'addNumbers' => $this->t('Add numbers'),
'addPunctuation' => $this->t('Add punctuation'),
'sameAsUsername' => $this->t('Make it different from your username'),
'weak' => $this->t('Weak'),
'fair' => $this->t('Fair'),
'good' => $this->t('Good'),
'strong' => $this->t('Strong'),
'username' => $this->currentUser
->getAccountName(),
];
}
$element['#attached']['library'][] = 'user/drupal.user';
$element['#attached']['drupalSettings']['password'] = $password_settings;
return $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.