public function miniorange_2fa_inline_registration::handle2FAReset in Google Authenticator / 2 Factor Authentication - 2FA 8.2
1 call to miniorange_2fa_inline_registration::handle2FAReset()
File
- src/
Form/ miniorange_2fa_inline_registration.php, line 1564 - 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
public function handle2FAReset(array &$form, FormStateInterface $form_state) {
$storage = $form_state
->getStorage();
$phone = isset($storage['page_four_values']['mo_auth_otpoversms_phone']) ? $storage['page_four_values']['mo_auth_otpoversms_phone'] : NULL;
$form_state
->setRebuild();
$method = $storage['page_three_values']['mo_auth_method'];
$email = $storage['page_one_values']['mo_auth_user_email'];
$customer = new MiniorangeCustomerProfile();
if (isset($storage['page_one_values']['mo_2fa_reset']) && $storage['page_one_values']['mo_2fa_reset'] === TRUE && $method != AuthenticationType::$KBA['code']) {
$miniorange_user = new MiniorangeUser($customer
->getCustomerID(), $email, $phone, NULL, $method == AuthenticationType::$AUTHY_AUTHENTICATOR['code'] || $method == AuthenticationType::$MICROSOFT_AUTHENTICATOR['code'] ? AuthenticationType::$GOOGLE_AUTHENTICATOR['code'] : $method);
// update user info
$user_api_handler = new UsersAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$user_update_response = $user_api_handler
->update($miniorange_user);
if ($user_update_response->status == 'SUCCESS') {
$database = \Drupal::database();
$database
->update('UserAuthenticationType')
->fields([
'activated_auth_methods' => AuthenticationType::getAuthType($method)['code'],
])
->condition('miniorange_registered_email', $email, '=')
->execute();
$type = 'status';
$updateMsg = t('Successfully updated your 2FA method to ') . AuthenticationType::getAuthType($method)['name'];
}
else {
$type = 'error';
$updateMsg = t('Facing issues in updating your 2FA method. Please try in your next login.');
}
\Drupal::messenger()
->addMessage($updateMsg, $type, TRUE);
$url = Url::fromRoute('user.login')
->toString();
$response = new RedirectResponse($url);
$response
->send();
exit;
}
}