public function test_google_authenticator::buildForm in Google Authenticator / 2 Factor Authentication - 2FA 8
Same name and namespace in other branches
- 8.2 src/Form/test_google_authenticator.php \Drupal\miniorange_2fa\Form\test_google_authenticator::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides FormInterface::buildForm
File
- src/
Form/ test_google_authenticator.php, line 24 - Email verification functions.
Class
- test_google_authenticator
- Menu callback for email verification.
Namespace
Drupal\miniorange_2fa\FormCode
public function buildForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state) {
$form['markup_top_2'] = array(
'#markup' => '<div class="mo_saml_table_layout_1"><div class="mo_saml_table_layout mo_saml_container">',
);
$form['markup_library'] = array(
'#attached' => array(
'library' => 'miniorange_2fa/miniorange_2fa.admin',
'library' => 'miniorange_2fa/miniorange_2fa.license',
),
);
global $base_url;
$url = $base_url . '/admin/config/people/miniorange_2fa/setup_twofactor';
// To check which method (Soft Token, Google Authenticator') is being tested by user
$query_param = \Drupal::service('path.current')
->getPath();
$url_parts = explode('/', $query_param);
if (in_array("soft-token", $url_parts)) {
$authTypeCode = AuthenticationType::$SOFT_TOKEN['code'];
$messageHeader = '<div class="mo2f-setup-header-top-left">Test Soft Token</div></div><div class="mo2f-info">Please enter the passcode generated on your miniOrange Authenticator app.</div>';
}
else {
$authTypeCode = AuthenticationType::$GOOGLE_AUTHENTICATOR['code'];
$messageHeader = '<div class="mo2f-setup-header-top-left">Test Google Authenticator</div></div><div class="mo2f-info">Please enter the passcode generated on your Google Authenticator app.</div>';
}
$form['header']['#markup'] = t('<div class="mo2f-setup-header">' . $messageHeader);
$form['mo_auth_googleauth_token'] = array(
'#type' => 'textfield',
'#maxlength' => 6,
'#title' => 'Passcode: ',
'#attributes' => array(
'placeholder' => t('Enter passcode.'),
'class' => array(
'mo2f-textbox',
'mo2f-textbox-otp',
),
'style' => 'width:200px',
'autofocus' => TRUE,
),
'#suffix' => '<br>',
);
$form['authTypeCode'] = array(
'#type' => 'hidden',
'#value' => $authTypeCode,
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Verify'),
);
$form['actions']['cancel'] = array(
'#markup' => '<span> </span><a href="' . $url . '"> Cancel Test</a>',
);
$form['main_layout_div_end'] = array(
'#markup' => '<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></div>',
);
MoAuthUtilities::AddsupportTab($form, $form_state);
return $form;
}