fix: user post and get
This commit is contained in:
parent
20a26ebd66
commit
b84c4fd8e3
@ -13,7 +13,7 @@ Eine auflistung von allen Funktionen und API-Endpunkten mit Erklärung.
|
|||||||
|
|
||||||
### User erstellen
|
### User erstellen
|
||||||
```shell
|
```shell
|
||||||
POST 127.0.0.1/DirektiveDesDons/signup
|
POST 127.0.0.1/DirektiveDesDons/user
|
||||||
|
|
||||||
BODY
|
BODY
|
||||||
{
|
{
|
||||||
|
30
index.php
30
index.php
@ -48,22 +48,22 @@ $app->get("/", function (array $req, Response $res) use ($db) {
|
|||||||
/*
|
/*
|
||||||
* User
|
* User
|
||||||
*/
|
*/
|
||||||
$app->get("/user", function (array $req, Response $res) {
|
$app->route("/user")
|
||||||
if (isset($req["user"])) {
|
->get(function (array $req, Response $res) {
|
||||||
$res->json(["id" => $req["user"]->id, "username" => $req["user"]->username, "email" => $req["user"]->email]);
|
if (isset($req["user"])) {
|
||||||
} else {
|
$res->json(["id" => $req["user"]->id, "username" => $req["user"]->username, "email" => $req["user"]->email]);
|
||||||
$res->json(["status" => HTTP_STATUS_CODE::FORBIDDEN, "message" => "You are not logged in. Goto '/login' to login"]);
|
} else {
|
||||||
}
|
$res->json(["status" => HTTP_STATUS_CODE::FORBIDDEN, "message" => "You are not logged in. Goto '/login' to login"]);
|
||||||
});
|
}
|
||||||
$app->post("/signup", function (array $req, Response $res) use ($db) {
|
})
|
||||||
$newUsername = $req["body"]["username"];
|
->post(function (array $req, Response $res) use ($db) {
|
||||||
$newPassword = $req["body"]["password"];
|
$newUsername = $req["body"]["username"];
|
||||||
$newEmail = $req["body"]["email"];
|
$newPassword = $req["body"]["password"];
|
||||||
$db->insert("utente", ["email" => "$newEmail", "parolaDordine" => "$newPassword", "nomeUtente" => "$newUsername"]);
|
$newEmail = $req["body"]["email"];
|
||||||
|
$db->insert("utente", ["email" => "$newEmail", "parolaDordine" => "$newPassword", "nomeUtente" => "$newUsername"]);
|
||||||
$res->send("Account Created", HTTP_STATUS_CODE::CREATED);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
$res->send("Account Created", HTTP_STATUS_CODE::CREATED);
|
||||||
|
});
|
||||||
$app->post("/login", function (array $req, Response $res) use ($db) {
|
$app->post("/login", function (array $req, Response $res) use ($db) {
|
||||||
$username = $req["body"]["username"];
|
$username = $req["body"]["username"];
|
||||||
$password = $req["body"]["password"];
|
$password = $req["body"]["password"];
|
||||||
|
Loading…
Reference in New Issue
Block a user