function miniorange_2fa_inline_registration::mo_auth_get_otp_over_sms_authentication_form in Google Authenticator / 2 Factor Authentication - 2FA 8
Same name and namespace in other branches
- 8.2 src/Form/miniorange_2fa_inline_registration.php \Drupal\miniorange_2fa\form\miniorange_2fa_inline_registration::mo_auth_get_otp_over_sms_authentication_form()
1 call to miniorange_2fa_inline_registration::mo_auth_get_otp_over_sms_authentication_form()
File
- src/
Form/ miniorange_2fa_inline_registration.php, line 1100
Class
Namespace
Drupal\miniorange_2fa\formCode
function mo_auth_get_otp_over_sms_authentication_form(array $form, \Drupal\Core\Form\FormStateInterface $form_state, $success_status, $message) {
$storage = $form_state
->getStorage();
$method = $storage['page_three_values']['mo_auth_method'];
$email = $storage['page_one_values']['mo_auth_user_email'];
$otp_over_sms = AuthenticationType::$SMS['code'];
$otp_over_email = AuthenticationType::$EMAIL['code'];
$otp_over_sms_and_email = AuthenticationType::$SMS_AND_EMAIL['code'];
$otp_over_phone = AuthenticationType::$OTP_OVER_PHONE['code'];
if ($method == $otp_over_sms) {
$authmethod = 'OTP Over SMS';
}
elseif ($method == $otp_over_sms_and_email) {
$authmethod = 'OTP Over SMS And Email';
}
elseif ($method == $otp_over_email) {
$authmethod = 'OTP Over Email';
}
elseif ($method == $otp_over_phone) {
$authmethod = 'OTP Over Phone';
}
$form['markup_library'] = array(
'#attached' => array(
'library' => array(
"miniorange_2fa/miniorange_2fa.admin",
"miniorange_2fa/miniorange_2fa.license",
),
),
);
$prefix = '<div class="mo2f-modal">
<div class="mo2f-modal-content">
<div class="mo2f-modal-container mo2f-modal-header">Configure ' . $authmethod . ' (Step 4/5)</div><div class="mo2f-modal-container">';
if ($success_status === FALSE) {
$prefix .= '<div class="mo2f-message mo2f-message-error">' . $message . '</div>';
}
if ($method == $otp_over_sms || $method == $otp_over_phone) {
$step1 = ' Verify your phone number.';
}
elseif ($method == $otp_over_sms_and_email) {
$step1 = ' Verify your phone number and email.';
}
elseif ($method == $otp_over_email) {
$step1 = 'Verify your email.';
}
$prefix .= '<div><div class="mo2f-info">' . $step1;
if ($method == $otp_over_sms_and_email || $method == $otp_over_email) {
$prefix .= '<br><input type="text" class="mo2f-textbox mo2f-textbox-otp" value="' . $email . '" disabled><br>';
}
$prefix .= '</div></div>';
$sufix = '</div><div class="mo2f-modal-container mo2f-modal-footer">';
if ($method != $otp_over_email) {
$form['mo_auth_otpoversms_phone'] = array(
'#type' => 'textfield',
'#id' => 'query_phone',
'#description' => t('Enter number with country code Eg. +00xxxxxxxxxx'),
'#attributes' => array(
'placeholder' => 'Phone Number',
'pattern' => '[\\+]?[0-9]{1,4}\\s?[0-9]{7,12}',
'class' => array(
'query_phone',
'mo2f-textbox',
'mo2f-textbox-otp',
),
'autofocus' => 'true',
),
'#required' => TRUE,
'#prefix' => $prefix,
'#suffix' => $sufix,
);
}
else {
$form['mo_auth_otpoversms_phone'] = array(
'#type' => 'textfield',
'#default_value' => $email,
'#disabled' => 'true',
'#description' => 'Your Email Id to which an OTP will be sent: ',
'#attributes' => array(
'class' => array(
'mo2f-textbox',
'mo2f-textbox-otp',
),
'autofocus' => 'true',
),
'#prefix' => $prefix,
'#suffix' => $sufix,
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Send OTP'),
'#submit' => array(
'::handle_page_four_submit',
),
);
return $form;
}