From 2860a01cf85ef96a97db5a3f896272a60560ff75 Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Thu, 12 Jan 2023 15:29:58 +0100 Subject: [PATCH] fix: login with Token --- BancaDati/BancaDati.php | 1 + index.php | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/BancaDati/BancaDati.php b/BancaDati/BancaDati.php index 790d024..0ad19f9 100644 --- a/BancaDati/BancaDati.php +++ b/BancaDati/BancaDati.php @@ -120,6 +120,7 @@ class BancaDati { try { return $this->pdo->query($sql)->fetch(); }catch (PDOException $e){ + var_dump($e); die; } } diff --git a/index.php b/index.php index 756988a..374358d 100644 --- a/index.php +++ b/index.php @@ -14,16 +14,16 @@ $db = new BancaDati(); $app->use("/", function (array &$req, Response $res) { if(isset($_COOKIE["TOKEN"])){ - // user mit token finden und im req übergeben $user = new User(); - $user->loginWithToken($_COOKIE["TOKEN"]); - $req["user"] = $user; + if($user->loginWithToken($_COOKIE["TOKEN"])){ + $req["user"] = $user; + } } }); $app->get("/", function (array $req, Response $res) { $res->send("Hello World"); - var_dump($req["user"]); + //var_dump($req["user"]); }); $app->get("/user", function (array $req, Response $res) {