API Usage refreshes
This commit is contained in:
parent
053724f9b7
commit
e20206d4a5
@ -36,6 +36,9 @@ class AdminAuth implements IMiddleware
|
||||
->httpCode(401)
|
||||
->json(["code" => "NotAllowed", "message" => "Not Authorized"]);
|
||||
}
|
||||
|
||||
// Keep fresh
|
||||
$user->keepFresh();
|
||||
} catch (Exception $err) {
|
||||
// No user with this token exists
|
||||
Response::response()
|
||||
|
||||
@ -26,7 +26,10 @@ class Auth implements IMiddleware
|
||||
}
|
||||
|
||||
try {
|
||||
User::getByToken($token);
|
||||
$user = User::getByToken($token);
|
||||
|
||||
// Keep fresh
|
||||
$user->keepFresh();
|
||||
} catch (Exception $err) {
|
||||
// No user with this token exists
|
||||
Response::response()
|
||||
|
||||
@ -20,7 +20,10 @@ class OptAuth implements IMiddleware
|
||||
}
|
||||
|
||||
try {
|
||||
User::getByToken($token);
|
||||
$user = User::getByToken($token);
|
||||
|
||||
// Keep fresh
|
||||
$user->keepFresh();
|
||||
} catch (Exception $err) {
|
||||
// No user with this token exists
|
||||
Response::response()
|
||||
|
||||
@ -214,7 +214,7 @@ class User implements JsonSerializable
|
||||
mail(
|
||||
$email,
|
||||
"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;
|
||||
@ -239,6 +239,7 @@ class User implements JsonSerializable
|
||||
WHERE id = :UID"
|
||||
);
|
||||
$stmt->bindValue(":UID", $user->getID());
|
||||
$stmt->execute();
|
||||
return User::getByID($user->getID());
|
||||
}
|
||||
|
||||
@ -542,6 +543,24 @@ class User implements JsonSerializable
|
||||
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
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user