You are here

public function MoAuthRemoveAccount::submitModalFormAjax in Google Authenticator / 2 Factor Authentication - 2FA 8.2

File

src/Form/MoAuthRemoveAccount.php, line 49

Class

MoAuthRemoveAccount

Namespace

Drupal\miniorange_2fa\Form

Code

public function submitModalFormAjax(array $form, FormStateInterface $form_state) {
  $response = new AjaxResponse();

  // If there are any form errors, AJAX replace the form.
  if ($form_state
    ->hasAnyErrors()) {
    $response
      ->addCommand(new ReplaceCommand('#modal_example_form', $form));
  }
  else {
    $utilities = new MoAuthUtilities();
    $variables_and_values = array(
      'mo_auth_customer_admin_email',
      'mo_auth_customer_admin_phone',
      'mo_auth_customer_id',
      'mo_auth_customer_api_key',
      'mo_auth_customer_token_key',
      'mo_auth_customer_app_secret',
      // $variable_and_values_2
      'mo_auth_2fa_license_type',
      'mo_auth_2fa_license_plan',
      'mo_auth_2fa_license_no_of_users',
      'mo_auth_2fa_ivr_remaining',
      'mo_auth_2fa_sms_remaining',
      'mo_auth_2fa_email_remaining',
      'mo_auth_2fa_license_expiry',
      'mo_auth_2fa_support_expiry',
      'mo_auth_status',
    );
    $utilities
      ->miniOrange_set_get_configurations($variables_and_values, 'CLEAR');
    $variables_and_values_2 = array(
      'mo_auth_enable_two_factor' => FALSE,
      'mo_auth_enforce_inline_registration' => FALSE,
    );
    $utilities
      ->miniOrange_set_get_configurations($variables_and_values_2, 'SET');
    \Drupal::messenger()
      ->addStatus(t('Your Account Has Been Removed Successfully!'));
    $_POST['value_check'] = 'False';
    $response
      ->addCommand(new RedirectCommand(\Drupal\Core\Url::fromRoute('miniorange_2fa.customer_setup', [
      'tab' => 'login',
    ])
      ->toString()));
  }
  return $response;
}