From e2c8313aa3faf679c17d669afcfd3f20c733bc71 Mon Sep 17 00:00:00 2001 From: Julien Oculi Date: Thu, 13 Jun 2024 12:19:02 +0200 Subject: [PATCH] fix: :bug: positive max age calculation --- src/session/mod.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/session/mod.ts b/src/session/mod.ts index dfd1f43..17c6b59 100644 --- a/src/session/mod.ts +++ b/src/session/mod.ts @@ -11,7 +11,7 @@ export class SessionStore { static get maxAge() { const halfHour = 30 * 60 * 1_000 - return Date.now() - halfHour + return Date.now() + halfHour } static createSession(): Session { return new Session(this.#store) @@ -19,13 +19,15 @@ export class SessionStore { static getSession(uuid: string): Session | undefined { // Check session validity + const halfHour = 30 * 60 * 1_000 + const maxOld = Date.now() - halfHour const session = this.#store.get(uuid) if (session === undefined) { return undefined } - if (session.timestamp < this.maxAge) { + if (session.timestamp < maxOld) { session.destroy() return undefined }