You are here

public static function Utilities::saml_resend_otp in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8

2 calls to Utilities::saml_resend_otp()
MiniorangeSamlCustomerSetup::miniorange_saml_resend_otp in src/Form/MiniorangeSamlCustomerSetup.php
Resend OTP.
miniorange_saml_sp_registration::miniorange_saml_register_popup in src/miniorange_saml_sp_registration.php

File

src/Utilities.php, line 809

Class

Utilities
This file is part of miniOrange SAML plugin.

Namespace

Drupal\miniorange_saml

Code

public static function saml_resend_otp($called_from_popup = false) {
  $db_edit = \Drupal::configFactory()
    ->getEditable('miniorange_saml.settings');
  $db_edit
    ->clear('miniorange_saml_tx_id')
    ->save();
  $username = \Drupal::config('miniorange_saml.settings')
    ->get('miniorange_saml_customer_admin_email');
  $phone = \Drupal::config('miniorange_saml.settings')
    ->get('miniorange_saml_customer_admin_phone');
  $customer_config = new MiniorangeSAMLCustomer($username, $phone, NULL, NULL);
  $send_otp_response = json_decode($customer_config
    ->sendOtp());
  if ($send_otp_response->status == 'SUCCESS') {

    // Store txID.
    $db_edit
      ->set('miniorange_saml_tx_id', $send_otp_response->txId)
      ->save();
    $db_edit
      ->set('miniorange_saml_status', 'VALIDATE_OTP')
      ->save();
    if ($called_from_popup == true) {
      miniorange_saml_sp_registration::miniorange_otp(false, true, false);
    }
    else {
      \Drupal::messenger()
        ->addMessage(t('Verify email address by entering the passcode sent to @username', array(
        '@username' => $username,
      )));
    }
  }
  else {
    if ($called_from_popup == true) {
      miniorange_saml_sp_registration::miniorange_otp(false, false, true);
    }
    else {
      \Drupal::messenger()
        ->addMessage(t('An error has been occured. Please try after some time'), 'error');
    }
  }
}