Store session in database.
[readifood.git] / www / index.php
index d88b321..d65e7c7 100644 (file)
   include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "functions.php")));
   include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "session.php")));
 
+  if (isset($_GET['code'])) {
+    try {
+      $auth0->getUser();
+      header("Location: https://" . $_SERVER['HTTP_HOST'] . "/");
+      exit;
+    }
+    catch (\Exception $e) {
+      include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "header.php")));
+      echo "<h1 class=\"printonly\">$charity</h1>\n";
+      echo "<h1>Not logged in!</h1>\n";
+      echo "<p>There was an authentication error.</p>\n";
+      include_once(join(DIRECTORY_SEPARATOR, array($lib_root, "footer.php")));
+    }
+  }
+
   $auth0_user = $auth0->getUser();
   if (isset($auth0_user)) $username = $auth0_user["sub"];
   else $username = null;