You are here

public function TfaRecoveryCode::getForm in Two-factor Authentication (TFA) 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

File

src/Plugin/TfaValidation/TfaRecoveryCode.php, line 94

Class

TfaRecoveryCode
Recovery validation class for performing recovery codes validation.

Namespace

Drupal\tfa\Plugin\TfaValidation

Code

public function getForm(array $form, FormStateInterface $form_state) {
  $form['code'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Enter one of your recovery codes'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Recovery codes were generated when you first set up TFA. Format: XXX XXX XXX'),
    '#attributes' => [
      'autocomplete' => 'off',
    ],
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['login'] = [
    '#type' => 'submit',
    '#button_type' => 'primary',
    '#value' => $this
      ->t('Verify'),
  ];
  return $form;
}