You are here

public function ChangePasswordForm::submitForm in Password Separate Form 8

Form submission 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 FormInterface::submitForm

File

src/Form/ChangePasswordForm.php, line 160

Class

ChangePasswordForm
Provides a user password reset form.

Namespace

Drupal\change_pwd_page\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $user = User::load($this->userProfile
    ->id());
  $user
    ->setPassword($form_state
    ->getValue('pass'));
  $user
    ->save();
  $this
    ->messenger()
    ->addStatus($this
    ->t('Your password has been changed.'));
}