You are here

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

Send OTP.

File

classes/CustomerSetup.php, line 108
Contains miniOrange Customer class.

Class

MiniorangeCustomerSetup
@file This class represents configuration for customer.

Code

public function sendOtp() {
  $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_CHALLENGE_API;
  $username = variable_get('mo_auth_customer_admin_email', NULL);
  $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')) {
    $error = array(
      '%method' => 'sendOtp',
      '%file' => 'CustomerSetup.php',
      '%error' => $response->message,
    );
    watchdog('mo_auth', 'Error at %method of %file: %error', $error);
  }
  return $response;
}