X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=lib%2Flib.php;fp=lib%2Flib.php;h=218c98febd45e3e5dde3d0017be7dd0f29748248;hp=da5eace26974dc7697c33e1e852b111ffe77a4e8;hb=3e8d21f3e93a304c7212e75810f6389cc2cb5bb8;hpb=0c40f0be4dd01156a31dec9c91958170061bb2f8 diff --git a/lib/lib.php b/lib/lib.php index da5eace..218c98f 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,22 +1,5 @@ internalGetData($username); + // TODO: change this to a pattern match for an actual key + if(!isset($token["tokenkey"])) return false; + if($token["tokenkey"] == "") return false; + } + + // sets the key for a user - this is assuming you dont want // to use one created by the application. returns false // if the key is invalid or the user doesn't exist. @@ -99,12 +90,6 @@ abstract class GoogleAuthenticator { } - // have user? - function userExists($username) { - // need to think about this - } - - // self explanitory? function deleteUser($username) { // oh, we need to figure out how to do thi? @@ -117,6 +102,7 @@ abstract class GoogleAuthenticator { // it function authenticateUser($username, $code) { + if(preg_match("/[0-9][0-9][0-9][0-9][0-9][0-9]/",$code)<1) return false; error_log("begin auth user"); $tokendata = $this->internalGetData($username); $asdf = print_r($tokendata, true); @@ -229,8 +215,11 @@ abstract class GoogleAuthenticator { } // create a url compatibile with google authenticator. - function createURL($user, $key,$toktype = "HOTP") { + function createURL($user) { // oddity in the google authenticator... hotp needs to be lowercase. + $data = $this->internalGetData($user); + $toktype = $data["tokentype"]; + $key = $data["tokenkey"]; $toktype = strtolower($toktype); if($toktype == "hotp") { $url = "otpauth://$toktype/$user?secret=$key&counter=1"; @@ -355,5 +344,15 @@ abstract class GoogleAuthenticator { private $getDatafunction; private $putDatafunction; private $errorText; + private $errorCode; + + /* + * error codes + * 1: Auth Failed + * 2: No Key + * 3: input code was invalid (user input an invalid code - must be 6 numerical digits) + * 4: user doesnt exist? + * 5: key invalid + */ } ?> \ No newline at end of file