API Usage refreshes
This commit is contained in:
parent
053724f9b7
commit
e20206d4a5
@ -36,6 +36,9 @@ class AdminAuth implements IMiddleware
|
|||||||
->httpCode(401)
|
->httpCode(401)
|
||||||
->json(["code" => "NotAllowed", "message" => "Not Authorized"]);
|
->json(["code" => "NotAllowed", "message" => "Not Authorized"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep fresh
|
||||||
|
$user->keepFresh();
|
||||||
} catch (Exception $err) {
|
} catch (Exception $err) {
|
||||||
// No user with this token exists
|
// No user with this token exists
|
||||||
Response::response()
|
Response::response()
|
||||||
|
|||||||
@ -26,7 +26,10 @@ class Auth implements IMiddleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
User::getByToken($token);
|
$user = User::getByToken($token);
|
||||||
|
|
||||||
|
// Keep fresh
|
||||||
|
$user->keepFresh();
|
||||||
} catch (Exception $err) {
|
} catch (Exception $err) {
|
||||||
// No user with this token exists
|
// No user with this token exists
|
||||||
Response::response()
|
Response::response()
|
||||||
|
|||||||
@ -20,7 +20,10 @@ class OptAuth implements IMiddleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
User::getByToken($token);
|
$user = User::getByToken($token);
|
||||||
|
|
||||||
|
// Keep fresh
|
||||||
|
$user->keepFresh();
|
||||||
} catch (Exception $err) {
|
} catch (Exception $err) {
|
||||||
// No user with this token exists
|
// No user with this token exists
|
||||||
Response::response()
|
Response::response()
|
||||||
|
|||||||
@ -214,7 +214,7 @@ class User implements JsonSerializable
|
|||||||
mail(
|
mail(
|
||||||
$email,
|
$email,
|
||||||
"Account activation GuestBookDB",
|
"Account activation GuestBookDB",
|
||||||
"Hello $username. To activate your account, visit https://khofmann.userpage.fu-berlin.de/phpCourse/exam/confirm?c=$guid"
|
"Hello $username. To activate your account, visit https://khofmann.userpage.fu-berlin.de/phpCourse/exam/confirm?code=$guid"
|
||||||
);
|
);
|
||||||
|
|
||||||
return $user;
|
return $user;
|
||||||
@ -239,6 +239,7 @@ class User implements JsonSerializable
|
|||||||
WHERE id = :UID"
|
WHERE id = :UID"
|
||||||
);
|
);
|
||||||
$stmt->bindValue(":UID", $user->getID());
|
$stmt->bindValue(":UID", $user->getID());
|
||||||
|
$stmt->execute();
|
||||||
return User::getByID($user->getID());
|
return User::getByID($user->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,6 +543,24 @@ class User implements JsonSerializable
|
|||||||
return ["pages" => intdiv($count, $limit + 1) + 1, "data" => $list];
|
return ["pages" => intdiv($count, $limit + 1) + 1, "data" => $list];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function keepFresh()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$db = Database::getInstance();
|
||||||
|
$stmt = $db->prepare(
|
||||||
|
"UPDATE
|
||||||
|
egb_benutzer
|
||||||
|
SET
|
||||||
|
tokenExpiry = DATE_ADD(NOW(), INTERVAL " . Config::getTokenExpiry() . "),
|
||||||
|
refreshExpiry = DATE_ADD(NOW(), INTERVAL " . Config::getRefreshTokenExpiry() . ")
|
||||||
|
WHERE id = :ID"
|
||||||
|
);
|
||||||
|
$stmt->bindValue(":ID", $this->getID());
|
||||||
|
$stmt->execute();
|
||||||
|
} catch (Exception $err) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Getters
|
* Getters
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user