You are here

public function GALoginGA::createURL in Google Authenticator login 7

Create authentication URL.

Overrides GoogleAuthenticator::createURL

File

./ga_login.class.php, line 107

Class

GALoginGA

Code

public function createURL($user, $data = NULL) {
  if (is_null($data)) {
    return parent::createURL($user);
  }
  else {
    $toktype = $data["tokentype"];
    $key = $this
      ->helperhex2b32($data["tokenkey"]);

    // Token counter should be one more then current token value,
    // otherwise it gets confused.
    $counter = $data["tokencounter"] + 1;
    $toktype = strtolower($toktype);
    if ($toktype == "hotp") {
      $url = "otpauth://{$toktype}/{$user}?secret={$key}&counter={$counter}";
    }
    else {
      $url = "otpauth://{$toktype}/{$user}?secret={$key}";
    }
    return $url;
  }
}