public function GoogleAuthenticator::setUser in Google Authenticator login 7
Same name and namespace in other branches
- 6 ga4php.php \GoogleAuthenticator::setUser()
Create a user.
File
- ./
ga4php.php, line 117 - Abstract GoogleAuthenticator class.
Class
- GoogleAuthenticator
- @file Abstract GoogleAuthenticator class.
Code
public function setUser($username, $ttype = "HOTP", $key = "", $hexkey = "") {
$ttype = strtoupper($ttype);
if ($ttype != "HOTP" && $ttype != "TOTP") {
return FALSE;
}
if ($key == "") {
$key = $this
->createBase32Key();
}
$hkey = $this
->helperb322hex($key);
if ($hexkey != "") {
$hkey = $hexkey;
}
$token = $this
->internalGetData($username);
$token["tokenkey"] = $hkey;
$token["tokentype"] = $ttype;
if (!$this
->internalPutData($username, $token)) {
return FALSE;
}
return $key;
}