Implemented token expiration tracking and user import

This commit is contained in:
overplayed 2025-03-15 19:58:07 -04:00
parent a0525e3007
commit 2f58aa563a
2 changed files with 6 additions and 2 deletions

6
db.php
View File

@ -1,6 +1,6 @@
<?php
define("DB_HOST", "localhost");
define("DB_USER", "ccah-user");
define("DB_USER", "ccah_user");
define("DB_PASS", "e_NQ,S^#sW6X:;nV!Uw.my");
define("DB_NAME", "ccah_assessment");
@ -8,4 +8,8 @@ $conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($conn->connect_error) {
die("Database connection failed: " . $conn->connect_error);
}
// Mark expired tokens
$conn->query("UPDATE users SET expired = 1 WHERE expiry_date < NOW() AND expired = 0");
?>

View File

@ -43,7 +43,7 @@ if (!$user) {
exit;
}
// Check if token is expired
if (strtotime($user['token_expires_at']) < time()) {
if ($user['expired'] == 1) {
http_response_code(403);
echo json_encode(["error" => "Authentication token has expired."]);
exit;