public function configure_otp_over_sms::buildForm in Google Authenticator / 2 Factor Authentication - 2FA 8
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/ configure_otp_over_sms.php, line 19
Class
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' => array(
"miniorange_2fa/miniorange_2fa.admin",
"miniorange_2fa/miniorange_2fa.license",
),
),
);
global $base_url;
$url = $base_url . '/admin/config/people/miniorange_2fa/setup_twofactor';
$user = User::load(\Drupal::currentUser()
->id());
$user_id = $user
->id();
$utilities = new MoAuthUtilities();
$custom_attribute = $utilities::get_users_custom_attribute($user_id);
$user_email = $custom_attribute[0]->miniorange_registered_email;
$customer = new MiniorangeCustomerProfile();
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $user_email, NULL, NULL, AuthenticationType::$SMS['code']);
$auth_api_handler = new AuthenticationAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$form['header']['#markup'] = '<div class="mo2f-setup-header"><div class="mo2f-setup-header-top-left">Configure OTP Over SMS</div></div><br>';
$form['miniorange_phone'] = array(
'#type' => 'textfield',
'#title' => t('Verify Your Phone'),
'#description' => 'Enter number with country code Eg. +00xxxxxxxxxx',
'#id' => 'query_phone',
'#attributes' => array(
'class' => array(
'query_phone',
),
'pattern' => '[\\+]?[0-9]{1,4}\\s?[0-9]{7,12}',
'placeholder' => 'Enter number with country code Eg. +00xxxxxxxxxx',
),
);
$form['verifyphone'] = array(
'#type' => 'submit',
'#value' => t('Validate'),
'#submit' => array(
'::mo_auth_configure_otp_over_sms_submit',
),
);
$form['miniorange_2fa_customer_setup_resendotp'] = array(
'#type' => 'submit',
'#value' => t('Resend OTP'),
'#submit' => array(
'::miniorange_saml_resend_otp',
),
'#suffix' => '<br><br>',
);
$form['miniorange_OTP'] = array(
'#type' => 'textfield',
'#maxlength' => 6,
'#attributes' => array(
'placeholder' => t('Enter passcode.'),
),
'#title' => t('OTP'),
);
$form['miniorange_saml_customer_validate_otp_button'] = array(
'#type' => 'submit',
'#value' => t('Validate OTP'),
'#submit' => array(
'::miniorange_saml_validate_otp_submit',
),
);
$form['actions']['cancel'] = array(
'#markup' => '<a href=" ' . $url . ' ">Cancel</a>',
);
$form['main_layout_div_end'] = array(
'#markup' => '<br><br><br><br><br><br><br><br><br><br><br><br></div>',
);
MoAuthUtilities::AddsupportTab($form, $form_state);
return $form;
}