public function ChangePasswordForm::validateForm in Password Separate Form 8
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ ChangePasswordForm.php, line 147
Class
- ChangePasswordForm
- Provides a user password reset form.
Namespace
Drupal\change_pwd_page\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
$current_pass_input = trim($form_state
->getValue('current_pass'));
if ($current_pass_input) {
$user = User::load(\Drupal::currentUser()
->id());
if (!$this->passwordHasher
->check($current_pass_input, $user
->getPassword())) {
$form_state
->setErrorByName('current_pass', $this
->t('The current password you provided is incorrect.'));
}
}
}