You are here

public function UserPasswordResetForm::submitForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Form/UserPasswordResetForm.php \Drupal\user\Form\UserPasswordResetForm::submitForm()

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

core/modules/user/src/Form/UserPasswordResetForm.php, line 103
Contains \Drupal\user\Form\UserPasswordResetForm.

Class

UserPasswordResetForm
Form controller for the user password forms.

Namespace

Drupal\user\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  /** @var $user \Drupal\user\UserInterface */
  $user = $form_state
    ->getValue('user');
  user_login_finalize($user);
  $this->logger
    ->notice('User %name used one-time login link at time %timestamp.', array(
    '%name' => $user
      ->getUsername(),
    '%timestamp' => $form_state
      ->getValue('timestamp'),
  ));
  drupal_set_message($this
    ->t('You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password.'));

  // Let the user's password be changed without the current password check.
  $token = Crypt::randomBytesBase64(55);
  $_SESSION['pass_reset_' . $user
    ->id()] = $token;
  $form_state
    ->setRedirect('entity.user.edit_form', array(
    'user' => $user
      ->id(),
  ), array(
    'query' => array(
      'pass-reset-token' => $token,
    ),
    'absolute' => TRUE,
  ));
}