You are here

public function AuthenticationAPIHandler::getGoogleAuthSecret in Google Authenticator / 2 Factor Authentication - 2FA 8.2

Same name and namespace in other branches
  1. 8 src/AuthenticationAPIHandler.php \Drupal\miniorange_2fa\AuthenticationAPIHandler::getGoogleAuthSecret()

File

src/AuthenticationAPIHandler.php, line 54

Class

AuthenticationAPIHandler

Namespace

Drupal\miniorange_2fa

Code

public function getGoogleAuthSecret(MiniorangeUser $user) {
  $fields = array(
    'customerKey' => $user
      ->getCustomerId(),
    'username' => $user
      ->getUsername(),
    'googleAuthenticatorName' => \Drupal::config('miniorange_2fa.settings')
      ->get('mo_auth_google_auth_app_name') == '' ? 'miniOrangeAuth' : \Drupal::config('miniorange_2fa.settings')
      ->get('mo_auth_google_auth_app_name'),
  );
  $json = json_encode($fields);
  $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$AUTH_GET_GOOGLE_AUTH_API;
  return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
}