public function GALoginHotpSetup::getSetupForm in Google Authenticator login 8
Get the setup form for the validation method.
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 TfaSetupInterface::getSetupForm
File
- src/
Plugin/ TfaSetup/ GALoginHotpSetup.php, line 59
Class
- GALoginHotpSetup
- HOTP setup class to setup HOTP validation.
Namespace
Drupal\ga_login\Plugin\TfaSetupCode
public function getSetupForm(array $form, FormStateInterface $form_state) {
$help_links = $this
->getHelpLinks();
$items = [];
foreach ($help_links as $item => $link) {
$items[] = Link::fromTextAndUrl($item, Url::fromUri($link, [
'attributes' => [
'target' => '_blank',
],
]));
}
$form['apps'] = [
'#theme' => 'item_list',
'#items' => $items,
'#title' => $this
->t('Install authentication code application on your mobile or desktop device:'),
];
$form['info'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('The two-factor authentication application will be used during this setup and for generating codes during regular authentication. If the application supports it, scan the QR code below to get the setup code otherwise you can manually enter the text code.'),
];
$form['seed'] = [
'#type' => 'textfield',
'#value' => $this->seed,
'#disabled' => TRUE,
'#description' => $this
->t('Enter this code into your two-factor authentication app or scan the QR code below.'),
];
// QR image of seed.
$form['qr_image'] = [
'#prefix' => '<div class="ga-login-qr-code"',
'#theme' => 'image',
'#uri' => $this
->getQrCodeUri(),
'#alt' => $this
->t('QR code for TFA setup'),
'#suffix' => '</div>',
];
// QR code css giving it a fixed width.
$form['page']['#attached']['html_head'][] = [
[
'#tag' => 'style',
'#value' => ".ga-login-qr-code { width:200px }",
],
'qrcode-css',
];
// Include code entry form.
$form = $this
->getForm($form, $form_state);
$form['actions']['login']['#value'] = $this
->t('Verify and save');
// Alter code description.
$form['code']['#description'] = $this
->t('A verification code will be generated after you scan the above QR code or manually enter the setup code. The verification code is six digits long.');
return $form;
}