function miniorange_2fa_inline_registration::mo_auth_get_otp_over_sms_validate_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_validate_form()
1 call to miniorange_2fa_inline_registration::mo_auth_get_otp_over_sms_validate_form()
File
- src/
Form/ miniorange_2fa_inline_registration.php, line 1204
Class
Namespace
Drupal\miniorange_2fa\formCode
function mo_auth_get_otp_over_sms_validate_form(array $form, \Drupal\Core\Form\FormStateInterface $form_state, $success_status, $message) {
$storage = $form_state
->getStorage();
$method = $storage['page_three_values']['mo_auth_method'];
$otp_over_sms = AuthenticationType::$SMS['code'];
$otp_over_sms_and_email = AuthenticationType::$SMS_AND_EMAIL['code'];
$otp_over_email = AuthenticationType::$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';
}
$email = $storage['page_one_values']['mo_auth_user_email'];
$phone = str_replace(' ', '', $storage['page_four_values']['mo_auth_otpoversms_phone']);
if ($success_status === TRUE) {
if ($method == $otp_over_sms) {
$message = 'We have sent an OTP to ' . $phone . '. Enter the OTP received to verify your phone.';
}
elseif ($method == $otp_over_sms_and_email) {
$message = 'We have sent an OTP to ' . $phone . ' and ' . $email . '. Enter the OTP received to verify your phone and email.';
}
elseif ($method == $otp_over_email) {
$message = 'We have sent an OTP to ' . $email . '. Enter the OTP received to verify your email.';
}
elseif ($method == $otp_over_phone) {
$message = 'You will get a call on ' . $phone . ' shortly, which prompts OTP. Please enter the OTP to verify your phone number.';
}
}
$message_div_class = $success_status === TRUE ? 'mo2f-message-status' : 'mo2f-message-error';
$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"><div class="mo2f-message ' . $message_div_class . '">' . $message . '</div>
<div class="mo2f-info">Enter the passcode:</div>
<div>';
$suffix = '</div><div class="mo2f-modal-container mo2f-modal-footer">';
$form['mo_auth_otpoversms_code'] = array(
'#type' => 'textfield',
'#attributes' => array(
'placeholder' => 'Enter the passcode',
'class' => array(
'mo2f-textbox',
'mo2f-textbox-otp',
),
'autofocus' => 'true',
),
'#maxlength' => 6,
'#prefix' => $prefix,
'#suffix' => $suffix,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Validate OTP'),
'#submit' => array(
'::handle_page_otp_validate_submit',
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#submit' => array(
'::handle_page_cancel',
),
);
return $form;
}