You are here

function ga_loginGA::createURL in Google Authenticator login 6

Overrides GoogleAuthenticator::createURL

File

./ga_login.class.php, line 96

Class

ga_loginGA

Code

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;
  }
}