$sql = "select * from users where user_name='$username'";
$res = $this->dbConnector->query($sql);
- if($res->fetchCount()>0) {
- $this->errorText = "User Already Exists, $username";
- return false;
- }
+ //if($res->fetchCount()>0) {
+ //$this->errorText = "User Already Exists, $username";
+ //return false;
+ //}
// and finally create 'em
- $this->dbConnector->query("insert into tokens values (NULL, '$key', 'HOTP','0')");
+ $hkey = $this->helperb322hex($key);
+ error_log("key for user $username is $hkey, $key");
+ $this->dbConnector->query("insert into tokens values (NULL, '$hkey', 'HOTP','0')");
$id = $this->dbConnector->lastInsertID();
$this->dbConnector->query("insert into users values (NULL, '$username', '$id')");
//}
// and finally create 'em
- $this->dbConnector->query("insert into tokens values (NULL, '$key', 'HOTP', '0')");
+ $hkey = $this->helperb322hex($key);
+ $this->dbConnector->query("insert into tokens values (NULL, '$hkey', 'HOTP', '0')");
$id = $this->dbConnector->lastInsertID();
$this->dbConnector->query("insert into users values (NULL, '$username', '$id')");
// create a url compatibile with google authenticator.
function createURL($user, $key) {
- $url = "otpauth://totp/$user?secret=$key";
- echo "url: $url\n";
+ $url = "otpauth://hotp/$user?secret=$key";
+ //echo "url: $url\n";
return $url;
}
// HMAC
$hash = hash_hmac ('sha1', $bin_counter, $key);
- return $this->oath_truncate($hash);
+ return str_pad($this->oath_truncate($hash), 6, "0", STR_PAD_LEFT);
}
function oath_truncate($hash, $length = 6)