X-Git-Url: http://git.pjr.cc/?p=ga4php.git;a=blobdiff_plain;f=example%2Flogin%2Findex.php;fp=example%2Flogin%2Findex.php;h=fc9ef2b557829d414946ecf246c250dc78bc53e9;hp=0000000000000000000000000000000000000000;hb=7d9ad0ded6fb7efc1d04f51ba86e5cf88ead0630;hpb=eb25b7f233389067c8e571f67f273477ec14792f diff --git a/example/login/index.php b/example/login/index.php new file mode 100644 index 0000000..fc9ef2b --- /dev/null +++ b/example/login/index.php @@ -0,0 +1,140 @@ +query($sql); + + foreach($res as $row) { + $passhash = $row["users_password"]; + } + + // user entered a tokencode, fail the login and tell the user + // if they dont have a token code assigned to them + if($tokencode != "") { + if(!$myga->hasToken($username)) { + $msg = urlencode("Attempted to login with a token when username isnt assigned one"); + header("Location: index.php?failure=$msg"); + } + } + + // check the password hash versus the login password + error_log("checking $passhash against $password (".sha1($password).")"); + if($passhash == sha1($password)) $passright = true; + else { + header("Location: index.php?failure=LoginIncorrect"); + return; + } + + // now get myGA to check the token code + error_log("passed password auth"); + if($myga->hasToken($username)) if(!$myga->authenticateUser($username, $tokencode)) { + header("Location: index.php?failure=LoginIncorrect"); + return; + } + + // and we're loged in + $_SESSION["loginname"] = "$username"; + + header("Location: index.php"); + return; +} + + + + +// and our "your logged in" page +function displayLogedInPage() +{ +?> + +

Welcome

+Welcome , you are logged in. +Click here to log out. + +"; + print_r($_REQUEST); + print_r($_SESSION); + echo ""; + + return; +} + + + + +?> + +

Welcome to Generic Site

+Note: if the user you've provisioned has not got a token code, its not required for login
+Please login: +Login Failure: ".$_REQUEST["failure"]."
"; +} +?> +
+ + + + + +
Username
Password
Pin Code
+
+
+
+
+
+ \ No newline at end of file