function authenticate_user::mo_auth_forgot_phone 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_forgot_phone()
File
- src/
Form/ authenticate_user.php, line 311 - 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_forgot_phone($form, FormStateInterface $form_state) {
global $base_url;
$customer = new MiniorangeCustomerProfile();
$url_parts = MoAuthUtilities::mo_auth_get_url_parts();
end($url_parts);
$user_id = prev($url_parts);
$custom_attribute = MoAuthUtilities::get_users_custom_attribute($user_id);
$user_email = $custom_attribute[0]->miniorange_registered_email;
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $user_email, NULL, NULL, AuthenticationType::$KBA['code']);
$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 ($response->status == 'SUCCESS') {
$moMfaSession['mo_challenge_response'] = $response;
$session
->replace(array(
'mo_auth' => $moMfaSession,
));
$session
->save();
$authType = AuthenticationType::getAuthType(AuthenticationType::$KBA['code']);
$form_state
->setRebuild();
return self::mo_auth_build_form($form, $base_url, $authType, $response, TRUE, '');
}
else {
global $base_url;
\Drupal::messenger()
->addError(t('An error occurred while processing your request. Please contact the administrator.'), TRUE);
$url = Url::fromRoute('user.login')
->toString();
$response = new RedirectResponse($url);
$response
->send();
}
}