Added the ability to edit and delete posts which includes uploading of images for the posts and managing those images
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
Vendored
+18
-5
@@ -36,15 +36,19 @@ class userRoutes implements routesInterface
|
||||
|
||||
if (empty($data["username"]) || empty($data["password"]))
|
||||
{
|
||||
// uh oh userData sent empty data
|
||||
// uh oh user sent empty data
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if ($this->user->checkUser($data["username"], $data["password"]))
|
||||
{
|
||||
// yay, userData is logged in
|
||||
// yay, user is logged in
|
||||
$_SESSION["token"] = $this->user->createToken($data["username"]);
|
||||
$_SESSION["username"] = $data["username"];
|
||||
|
||||
$inactive = 60 * 60 * 48; // 2 days
|
||||
$_SESSION["timeout"] = time() + $inactive;
|
||||
|
||||
$response->getBody()->write(json_encode(array("token" => $_SESSION["token"])));
|
||||
return $response;
|
||||
}
|
||||
@@ -62,15 +66,24 @@ class userRoutes implements routesInterface
|
||||
{
|
||||
if (empty($_SESSION["token"]) && empty($_SESSION["username"]))
|
||||
{
|
||||
// uh oh userData not logged in
|
||||
// uh oh user not logged in
|
||||
return $response->withStatus(401);
|
||||
}
|
||||
|
||||
$inactive = 60 * 60 * 48; // 2 days
|
||||
$sessionLife = time() - $_SESSION["timeout"];
|
||||
if ($sessionLife > $inactive)
|
||||
{
|
||||
// uh oh user session expired
|
||||
session_destroy();
|
||||
return $response->withStatus(401);
|
||||
}
|
||||
|
||||
if (empty($_SESSION["token"]))
|
||||
{
|
||||
// userData is logged in but no token was created
|
||||
// user is logged in but no token was created
|
||||
$_SESSION["token"] = $this->user->createToken($_SESSION["username"]);
|
||||
return $response;
|
||||
return $response->withStatus(201);
|
||||
}
|
||||
|
||||
$response->getBody()->write(json_encode(array("token" => $_SESSION["token"])));
|
||||
|
||||
Reference in New Issue
Block a user