fix: login with Token

This commit is contained in:
Johannes Kantz 2023-01-12 15:29:58 +01:00
parent a887921e5d
commit 2860a01cf8
2 changed files with 5 additions and 4 deletions

View File

@ -120,6 +120,7 @@ class BancaDati {
try { try {
return $this->pdo->query($sql)->fetch(); return $this->pdo->query($sql)->fetch();
}catch (PDOException $e){ }catch (PDOException $e){
var_dump($e);
die; die;
} }
} }

View File

@ -14,16 +14,16 @@ $db = new BancaDati();
$app->use("/", function (array &$req, Response $res) { $app->use("/", function (array &$req, Response $res) {
if(isset($_COOKIE["TOKEN"])){ if(isset($_COOKIE["TOKEN"])){
// user mit token finden und im req übergeben
$user = new User(); $user = new User();
$user->loginWithToken($_COOKIE["TOKEN"]); if($user->loginWithToken($_COOKIE["TOKEN"])){
$req["user"] = $user; $req["user"] = $user;
}
} }
}); });
$app->get("/", function (array $req, Response $res) { $app->get("/", function (array $req, Response $res) {
$res->send("Hello World"); $res->send("Hello World");
var_dump($req["user"]); //var_dump($req["user"]);
}); });
$app->get("/user", function (array $req, Response $res) { $app->get("/user", function (array $req, Response $res) {