function authenticate_user::mo_auth_build_kba_authentication_form in Google Authenticator / 2 Factor Authentication - 2FA 8
Same name and namespace in other branches
- 8.2 src/Form/authenticate_user.php \Drupal\miniorange_2fa\form\authenticate_user::mo_auth_build_kba_authentication_form()
1 call to authenticate_user::mo_auth_build_kba_authentication_form()
File
- src/
Form/ authenticate_user.php, line 395 - This is used to authenticate user during login.
Class
- authenticate_user
- @file This is used to authenticate user during login.
Namespace
Drupal\miniorange_2fa\formCode
function mo_auth_build_kba_authentication_form($form, $base_url, $challenge_response, $success_message) {
if ($success_message === TRUE) {
$message = 'Please answer the following questions.';
}
else {
$message = 'The answers you have entered are incorrect.';
}
$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['header']['#markup'] .= '<div class="mo2f-kba-header mo2f-kba-row">
<div class="mo2f-kba-srno"></div>
<div class="mo2f-kba-question"></div>
<div class="mo2f-kba-answer"></div>
</div>';
$i = 0;
$questions = isset($challenge_response->questions) ? $challenge_response->questions : '';
if (is_array($questions)) {
foreach ($questions as $ques) {
$i++;
$form['mo2f_kbaanswer' . $i] = array(
'#type' => 'textfield',
'#title' => t($i . '. ' . $ques->question),
'#size' => 45,
'#required' => TRUE,
'#attributes' => array(
'placeholder' => 'Enter your answer',
),
);
$form['mo2f_kbaquestion' . $i] = array(
'#type' => 'hidden',
'#value' => $ques->question,
);
}
}
$form['txId'] = array(
'#type' => 'hidden',
'#value' => isset($challenge_response->txId) ? $challenge_response->txId : '',
);
$form['mo_message'] = $message;
return $form;
}