public function authenticate_user::mo_auth_challenge_user in Google Authenticator / 2 Factor Authentication - 2FA 8.2
Same name and namespace in other branches
- 8 src/Form/authenticate_user.php \Drupal\miniorange_2fa\form\authenticate_user::mo_auth_challenge_user()
1 call to authenticate_user::mo_auth_challenge_user()
- authenticate_user::buildForm in src/
Form/ authenticate_user.php - Form constructor.
File
- src/
Form/ authenticate_user.php, line 102 - 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
public function mo_auth_challenge_user($form, $user_email, $user_id, FormStateInterface $form_state) {
$customer = new MiniorangeCustomerProfile();
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $user_email, NULL, NULL, NULL);
$auth_api_handler = new AuthenticationAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$response = $auth_api_handler
->challenge($miniorange_user);
$session = MoAuthUtilities::getSession();
$moMfaSession = $session
->get("mo_auth", null);
if (is_object($response) && $response->status == 'SUCCESS') {
$moMfaSession['mo_challenge_response'] = $response;
$session
->replace(array(
'mo_auth' => $moMfaSession,
));
$session
->save();
return $moMfaSession;
}
else {
MoAuthUtilities::mo_add_loggers_for_failures(is_object($response) ? $response->message : '-', 'error');
\Drupal::messenger()
->addMessage(t('An error occured while processing your request. Please contact administrator.'), 'error', TRUE);
$url = Url::fromRoute('user.login')
->toString();
$response = new RedirectResponse($url);
$response
->send();
exit;
}
}