From 591db4dfa36aabcd52c29b9430548ad326edbb43 Mon Sep 17 00:00:00 2001 From: rodude123 Date: Mon, 1 Jan 2024 19:09:23 +0000 Subject: [PATCH] Uncommented the code, shouldn't have been commented in the first place Signed-off-by: rodude123 --- src/api/user/userRoutes.php | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/api/user/userRoutes.php b/src/api/user/userRoutes.php index 009b813..993c209 100644 --- a/src/api/user/userRoutes.php +++ b/src/api/user/userRoutes.php @@ -168,27 +168,24 @@ class userRoutes implements routesInterface $this->samlAuth->processResponse(); $attributes = $this->samlAuth->getAttributes(); -// $username = $attributes["username"][0]; -// $email = $attributes["email"][0]; + $username = $attributes["username"][0]; + $email = $attributes["email"][0]; - $response->getBody()->write(json_encode($attributes)); - return $response; + if ($this->user->checkSAMLUser($username, $email)) + { + // yay, user is logged in + $_SESSION["token"] = $this->user->createToken($username); + $_SESSION["username"] = $username; + $_SESSION["email"] = $email; -// if ($this->user->checkSAMLUser($username, $email)) -// { -// // yay, user is logged in -// $_SESSION["token"] = $this->user->createToken($username); -// $_SESSION["username"] = $username; -// $_SESSION["email"] = $email; -// -// $inactive = 60 * 60 * 48; // 2 days -// $_SESSION["timeout"] = time() + $inactive; -// -// return $response->withHeader("Location", "https://rohitpai.co.uk/editor/editor.html")->withStatus(302); -// } -// -// $response->getBody()->write(json_encode(array("error" => "Unauthorised"))); -// return $response->withStatus(401); + $inactive = 60 * 60 * 48; // 2 days + $_SESSION["timeout"] = time() + $inactive; + + return $response->withHeader("Location", "https://rohitpai.co.uk/editor/editor.html")->withStatus(302); + } + + $response->getBody()->write(json_encode(array("error" => "Unauthorised"))); + return $response->withStatus(401); }); $app->post("/user/changePassword", function (Request $request, Response $response)