You are here

public function test_qrcode_authentication::submitForm in Google Authenticator / 2 Factor Authentication - 2FA 8.2

Same name and namespace in other branches
  1. 8 src/Form/test_qrcode_authentication.php \Drupal\miniorange_2fa\Form\test_qrcode_authentication::submitForm()

Form submit handler for email verify.

Overrides FormInterface::submitForm

File

src/Form/test_qrcode_authentication.php, line 130
Email verification functions.

Class

test_qrcode_authentication
Menu callback for email verification.

Namespace

Drupal\miniorange_2fa\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Clear all the messages
  \Drupal::messenger()
    ->deleteAll();
  $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);
  if ($response->status == 'SUCCESS') {
    $message = t('You have successfully completed the test.');
    MoAuthUtilities::show_error_or_success_message($message, 'status');
    return;
  }
  elseif ($response->status == 'FAILED') {
    $message = t('Authentication failed.');
  }
  else {
    $message = t('An error occurred while processing your request. Please try again.');
  }
  MoAuthUtilities::show_error_or_success_message($message, 'error');
  return;
}