added varius components for supporting user website.
[ga4php.git] / authserver / www / user_actions.php
diff --git a/authserver/www/user_actions.php b/authserver/www/user_actions.php
new file mode 100644 (file)
index 0000000..70e281a
--- /dev/null
@@ -0,0 +1,38 @@
+<?php 
+require_once("../lib/authClient.php");
+
+$myAC = new GAAuthClient();
+
+
+$loggedin = false;
+session_start();
+
+if(isset($_SESSION["loggedin"])) if($_SESSION["loggedin"]) {
+       error_log("session exists, poof!");
+       $loggedin = true;
+} else {
+       error_log("no session");
+       $loggedin = false;
+}
+
+if(isset($_REQUEST["action"])) {
+       error_log("action set: ".$_REQUEST["action"]);
+       switch($_REQUEST["action"]) {
+               case "login":
+                       error_log("being login");
+                       $username = $_REQUEST["username"];
+                       $token = $_REQUEST["tokencode"];
+                       
+                       if($myAC->authUserToken($username, $token)) {
+                               
+                               $_SESSION["loggedin"] = true;
+                               $_SESSION["username"] = $username;
+                               header("Location: index.php");
+                       } else {
+                               error_log("login failed, $username, $token");
+                               header("Location: index.php?message=loginfail");
+                       }
+                       break;
+       }
+}
+?>
\ No newline at end of file