From 649f386b9c1a08e12669c6c3acdb57928587cf27 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Thu, 21 Aug 2025 19:56:09 +0500 Subject: feat: validate tokens --- auth/validate.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 auth/validate.php diff --git a/auth/validate.php b/auth/validate.php new file mode 100644 index 0000000..c1cc149 --- /dev/null +++ b/auth/validate.php @@ -0,0 +1,25 @@ +prepare('SELECT user_id FROM tokens WHERE `hash` = ?'); + $stmt->execute([$hash]); + $token = $stmt->fetch(PDO::FETCH_ASSOC) ?: null; + + if (!$token) { + exit(create_alert('/', 401, 'Incorrect token.', null)); + } + + exit(create_alert('/', 200, null, ['id' => $token['user_id']])); +} \ No newline at end of file -- cgit v1.2.3