function UserLoginForm::submitForm

Same name and namespace in other branches
  1. 9 core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::submitForm()
  2. 8.9.x core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::submitForm()
  3. 11.x core/modules/user/src/Form/UserLoginForm.php \Drupal\user\Form\UserLoginForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/user/src/Form/UserLoginForm.php, line 146

Class

UserLoginForm
Provides a user login form.

Namespace

Drupal\user\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $uid = $form_state->get('uid');
    if (!$uid) {
        return;
    }
    $account = $this->userStorage
        ->load($uid);
    // A destination was set, probably on an exception controller.
    if (!$this->getRequest()->request
        ->has('destination')) {
        $form_state->setRedirect('entity.user.canonical', [
            'user' => $account->id(),
        ]);
    }
    else {
        $this->getRequest()->query
            ->set('destination', $this->getRequest()->request
            ->get('destination'));
    }
    user_login_finalize($account);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.