You are here

function GoogleAuthenticator::createURL in Google Authenticator login 6

Same name and namespace in other branches
  1. 7 ga4php.php \GoogleAuthenticator::createURL()
1 call to GoogleAuthenticator::createURL()
ga_loginGA::createURL in ./ga_login.class.php
1 method overrides GoogleAuthenticator::createURL()
ga_loginGA::createURL in ./ga_login.class.php

File

./ga4php.php, line 272

Class

GoogleAuthenticator

Code

function createURL($user) {

  // oddity in the google authenticator... hotp needs to be lowercase.
  $data = $this
    ->internalGetData($user);
  $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}";
  }

  //echo "url: $url\n";
  return $url;
}