public function test_email_verification::submitForm in Google Authenticator / 2 Factor Authentication - 2FA 8
Same name and namespace in other branches
- 8.2 src/Form/test_email_verification.php \Drupal\miniorange_2fa\Form\test_email_verification::submitForm()
Form submit handler for email verify.
Overrides FormInterface::submitForm
File
- src/
Form/ test_email_verification.php, line 122 - Email verification functions.
Class
- test_email_verification
- Menu callback for email verification.
Namespace
Drupal\miniorange_2fa\FormCode
public function submitForm(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
$form_state
->setRebuild();
$input = $form_state
->getUserInput();
$txId = $input['txId'];
$customer = new MiniorangeCustomerProfile();
$auth_api_handler = new AuthenticationAPIHandler($customer
->getCustomerID(), $customer
->getAPIKey());
$response = $auth_api_handler
->getAuthStatus($txId);
// Clear all the messages
\Drupal::messenger()
->deleteAll();
// read API response
if ($response->status == 'SUCCESS') {
$message = 'You have successfully completed the test.';
MoAuthUtilities::show_error_or_success_message($message, 'status');
}
elseif ($response->status == 'DENIED') {
$message = 'You have denied the transaction.';
MoAuthUtilities::show_error_or_success_message($message, 'error');
}
else {
$message = 'An error occured while processing your request. Please try again.';
MoAuthUtilities::show_error_or_success_message($message, 'error');
}
}