You are here

public function UsersAPIHandler::update in Google Authenticator / 2 Factor Authentication - 2FA 7

File

classes/UsersAPIHandler.php, line 12

Class

UsersAPIHandler

Code

public function update(MiniorangeUser $user) {
  if (is_string($user
    ->getAuthType()) && AuthenticationType::isCodeBelongsToAAuthenticator($user
    ->getAuthType())) {
    $user
      ->setAuthType(AuthenticationType::$GOOGLE_AUTHENTICATOR['code']);
  }
  $fields = array(
    'customerKey' => $user
      ->getCustomerId(),
    'username' => $user
      ->getUsername(),
    'phone' => $user
      ->getPhone(),
    'authType' => $user
      ->getAuthType(),
    'transactionName' => MoAuthConstants::$PLUGIN_NAME,
  );
  $json = json_encode($fields);
  $url = MoAuthConstants::getBaseUrl() . MoAuthConstants::$USERS_UPDATE_API;
  return MoAuthUtilities::callService($this->customerId, $this->apiKey, $url, $json);
}