You are here

public function EntryForm::submitForm in Two-factor Authentication (TFA) 8

If the form is passes validation, the user should get logged in.

Overrides FormInterface::submitForm

File

src/Form/EntryForm.php, line 264

Class

EntryForm
TFA entry form.

Namespace

Drupal\tfa\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $user = $form_state
    ->getValue('account');

  // @todo This could be improved with EventDispatcher.
  if (!empty($this->tfaLoginPlugins)) {
    foreach ($this->tfaLoginPlugins as $plugin) {
      if (method_exists($plugin, 'submitForm')) {
        $plugin
          ->submitForm($form, $form_state);
      }
    }
  }
  user_login_finalize($user);

  // @todo Should finalize() be after user_login_finalize or before?!
  // @todo This could be improved with EventDispatcher.
  $this
    ->finalize();
  $this->flood
    ->clear('tfa.failed_validation', $this->floodIdentifier);
  $form_state
    ->setRedirect('<front>');
}