done #3

Merged
PBS2H21ASH merged 19 commits from done into don 2023-01-24 20:11:21 +01:00
Showing only changes of commit e8775385cf - Show all commits

View File

@ -11,8 +11,7 @@ use Router\Router;
use Router\Route;
use BancaDati\BancaDati;
abstract class HTTP_STATUS_CODE
{
abstract class HTTP_STATUS_CODE {
const OK = 200;
const CREATED = 201;
const BAD_REQUEST = 400;
@ -41,8 +40,9 @@ $app->use("/", function (array &$req, Response $res) {
* Home
*/
$app->get("/", function (array $req, Response $res) use ($db) {
$res->send("Hello World");
//var_dump($req["user"]);
$res->json(["message" => "",
"name" => "Shopping List",
"authors" => "Simon Bock, Johannes Kantz & Malte Schulze Hobeling"]);
});
/*
@ -77,9 +77,9 @@ $app->post("/login", function( array $req, Response $res) use ($db) {
if ($usertoken) {
setcookie("TOKEN", $usertoken, time() + 3600); // 1h
$res->send("Login successful" . "token: " . $usertoken);
$res->json(["message" => "Login successful", "token" => $usertoken]);
} else {
$res->send("Login failed", HTTP_STATUS_CODE::FORBIDDEN);
$res->json(["message" => "Login failed"], HTTP_STATUS_CODE::FORBIDDEN);
}
});