fix: login with Token
This commit is contained in:
parent
a887921e5d
commit
2860a01cf8
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user