UserLoginForm::submitForm

public UserLoginForm::submitForm(array &$form, FormStateInterface $form_state)

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/UserLoginForm.php, line 129

Class

UserLoginForm
Provides a user login form.

Namespace

Drupal\user\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $account = $this->userStorage->load($form_state->get('uid'));

  // A destination was set, probably on an exception controller,
  if (!$this->getRequest()->request->has('destination')) {
    $form_state->setRedirect(
    'entity.user.canonical', 
    array('user' => $account->id())
    );
  }
  else {
    $this->getRequest()->query->set('destination', $this->getRequest()->request->get('destination'));
  }

  user_login_finalize($account);
}
doc_Drupal
2016-10-29 09:52:43
Comments
Leave a Comment

Please login to continue.