function mo_auth_build_otp_over_sms_form in Google Authenticator / 2 Factor Authentication - 2FA 7
1 call to mo_auth_build_otp_over_sms_form()
File
- ./
authenticate_user.inc, line 474 - This is used to authenticate user during login.
Code
function mo_auth_build_otp_over_sms_form($form, $base_url, $challenge_response, $method_to_test, $success_message = TRUE, $empty_token = FALSE) {
$phone_no = '';
if (isset($challenge_response->phoneDelivery->contact)) {
$phone_no = $challenge_response->phoneDelivery->contact;
$phone_no = substr_replace($phone_no, "*******", 0, -4);
}
if ($success_message === TRUE) {
if ($method_to_test === 'OTP OVER SMS AND EMAIL') {
$message = t('Please enter the passcode sent to your mobile phone and email.');
}
elseif ($method_to_test === 'OTP OVER SMS') {
$message = t('Please enter the OTP/passcode sent to your mobile phone <strong>' . $phone_no . '</strong>.');
}
elseif ($method_to_test === 'OTP OVER PHONE') {
$message = 'Please enter the OTP/passcode prompted on phone call - <strong>' . $phone_no . '</strong>.';
}
}
elseif ($empty_token) {
$message = t('The OTP field is required. Please try again.');
}
else {
$message = t('The OTP you have entered is incorrect. Please enter the valid OTP.');
}
$message_div_class = $success_message === TRUE ? 'mo2f-message-status' : 'mo2f-message-error';
$form['header']['#markup'] .= t('<div class="mo2f-message ' . $message_div_class . '">' . $message . '</div>');
$form['token'] = array(
'#type' => 'textfield',
'#title' => t('Please enter the passcode you received:'),
'#attributes' => array(
'autofocus' => 'true',
),
);
$submit_attributes = array();
$form['submit_attributes'] = $submit_attributes;
$form['mo_message'] = $message;
return $form;
}