You are here

public function MiniorangeCustomerSetup::sendOtp in Google Authenticator / 2 Factor Authentication - 2FA 8

Same name and namespace in other branches
  1. 8.2 src/MiniorangeCustomerSetup.php \Drupal\miniorange_2fa\MiniorangeCustomerSetup::sendOtp()

Send OTP.

File

src/MiniorangeCustomerSetup.php, line 92
Contains miniOrange Customer class.

Class

MiniorangeCustomerSetup
@file This class represents configuration for customer.

Namespace

Drupal\miniorange_2fa

Code

public function sendOtp() {
  $url = MoAuthConstants::$AUTH_CHALLENGE_API;
  $username = \Drupal::config('miniorange_2fa.settings')
    ->get('mo_auth_customer_admin_email');
  $fields = array(
    'customerKey' => $this->defaultCustomerId,
    'email' => $username,
    'authType' => AuthenticationType::$EMAIL['code'],
  );
  $json = json_encode($fields);
  $response = MoAuthUtilities::callService($this->defaultCustomerId, $this->defaultCustomerApiKey, $url, $json);
  if (json_last_error() == JSON_ERROR_NONE && strcasecmp($response->status, 'CURL_ERROR') == 0) {
    \Drupal::logger('miniorange_2fa')
      ->error($response->message);
  }
  return $response;
}