From 88d4007300165797788fe16c99ef37357d367b9a Mon Sep 17 00:00:00 2001 From: wistfulvariable <62183258+wistfulvariable@users.noreply.github.com> Date: Mon, 23 Mar 2026 10:07:12 -0400 Subject: [PATCH] Fix token validation to check expiry --- src/auth.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/auth.ts b/src/auth.ts index 1288d43..11d4325 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,5 +1,9 @@ export function validateToken(token: string): boolean { - return token.length > 0 + if (!token || token.length === 0) return false + const parts = token.split('.') + if (parts.length !== 3) return false + const payload = JSON.parse(atob(parts[1])) + return payload.exp > Date.now() / 1000 } export function login(username: string, password: string) {