You are here

public function GALoginHotpValidation::getForm in Google Authenticator login 8

Get TFA process form from plugin.

Parameters

array $form: The configuration form array.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array Form API array.

Overrides TfaValidationInterface::getForm

1 call to GALoginHotpValidation::getForm()
GALoginHotpSetup::getSetupForm in src/Plugin/TfaSetup/GALoginHotpSetup.php
Get the setup form for the validation method.

File

src/Plugin/TfaValidation/GALoginHotpValidation.php, line 134

Class

GALoginHotpValidation
HOTP validation class for performing HOTP validation.

Namespace

Drupal\ga_login\Plugin\TfaValidation

Code

public function getForm(array $form, FormStateInterface $form_state) {
  $message = $this
    ->t('Verification code is application generated and @length digits long.', [
    '@length' => $this->codeLength,
  ]);
  if ($this
    ->getUserData('tfa', 'tfa_recovery_code', $this->uid, $this->userData)) {
    $message .= '<br/>' . $this
      ->t("Can't access your account? Use one of your recovery codes.");
  }
  $form['code'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Application verification code'),
    '#description' => $message,
    '#required' => TRUE,
    '#attributes' => [
      'autocomplete' => 'off',
    ],
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['login'] = [
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#value' => $this
      ->t('Verify'),
  ];
  return $form;
}