function miniorange_2fa_inline_registration::mo_auth_get_otp_over_sms_authentication_form in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Same name and namespace in other branches
- 8 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 1228 - Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.
Class
- miniorange_2fa_inline_registration
- @file Page 1: Select Email address. Page 2: Verify OTP. Page 3: Select Auth Method. Page 4: Configure Auth Method. Page 5: Configure KBA.
Namespace
Drupal\miniorange_2fa\formCode
function mo_auth_get_otp_over_sms_authentication_form(array $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 = t(AuthenticationType::$SMS['name']);
}
elseif ($method == $otp_over_sms_and_email) {
$authmethod = t(AuthenticationType::$SMS_AND_EMAIL['name']);
}
elseif ($method == $otp_over_email) {
$authmethod = t(AuthenticationType::$OTP_OVER_EMAIL['name']);
}
elseif ($method == $otp_over_phone) {
$authmethod = t(AuthenticationType::$OTP_OVER_PHONE['name']);
}
$form['markup_library'] = array(
'#attached' => array(
'library' => array(
"miniorange_2fa/miniorange_2fa.admin",
"miniorange_2fa/miniorange_2fa.license",
),
),
);
$stepMessage = $this
->is2FAResetRequest($form_state) ? '' : ' ' . t('(Step 4/5)');
$prefix = '<div class="mo2f-modal">
<div class="mo2f-modal-content">
<div class="mo2f-modal-container mo2f-modal-header">' . t('Configure ') . $authmethod . $stepMessage . ' </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 = t('Verify your phone number.');
}
elseif ($method == $otp_over_sms_and_email) {
$step1 = t('Verify your phone number and email.');
}
elseif ($method == $otp_over_email) {
$step1 = t('Verify your email.');
}
$prefix .= '<div><div class="mo2f-info">' . $step1;
if ($method == $otp_over_sms_and_email || $method == $otp_over_email) {
$prefix .= '<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">';
$request = \Drupal::request();
$session = $request
->getSession();
$moMfaSession = $session
->get("mo_auth", null);
$phoneNumber = MoAuthUtilities::getUserPhoneNumber($moMfaSession['uid']);
if ($method != $otp_over_email) {
$form['mo_auth_otpoversms_phone'] = array(
'#type' => 'textfield',
'#id' => 'query_phone',
'#description' => t('<strong>Note:</strong> Enter number with country code Eg. +00xxxxxxxxxx'),
'#attributes' => array(
'placeholder' => t('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,
);
if (!is_null($phoneNumber)) {
$form['mo_auth_otpoversms_phone']['#default_value'] = $phoneNumber;
}
}
else {
$form['mo_auth_otpoversms_phone'] = array(
'#type' => 'textfield',
'#default_value' => $email,
'#disabled' => 'true',
'#description' => t('<strong>Note: </strong>Your Email Id to which an OTP will be sent'),
'#attributes' => array(
'class' => array(
'mo2f-textbox',
'mo2f-textbox-otp',
),
'autofocus' => TRUE,
),
'#required' => TRUE,
'#prefix' => $prefix,
'#suffix' => $sufix,
);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['send'] = array(
'#type' => 'submit',
'#value' => t('Send OTP'),
'#submit' => array(
'::handle_page_four_submit',
),
'#attributes' => array(
'class' => array(
'mo2f_button',
),
),
);
$form['actions']['cancel'] = array(
'#type' => 'submit',
'#value' => t('Cancel'),
'#limit_validation_errors' => array(),
'#submit' => array(
'::handle_page_cancel',
),
'#attributes' => array(
'class' => array(
'mo2f_button',
),
),
);
return $form;
}