fix: 🐛 positive max age calculation
This commit is contained in:
parent
a1844176bb
commit
e2c8313aa3
|
@ -11,7 +11,7 @@ export class SessionStore {
|
||||||
|
|
||||||
static get maxAge() {
|
static get maxAge() {
|
||||||
const halfHour = 30 * 60 * 1_000
|
const halfHour = 30 * 60 * 1_000
|
||||||
return Date.now() - halfHour
|
return Date.now() + halfHour
|
||||||
}
|
}
|
||||||
static createSession(): Session {
|
static createSession(): Session {
|
||||||
return new Session(this.#store)
|
return new Session(this.#store)
|
||||||
|
@ -19,13 +19,15 @@ export class SessionStore {
|
||||||
|
|
||||||
static getSession(uuid: string): Session | undefined {
|
static getSession(uuid: string): Session | undefined {
|
||||||
// Check session validity
|
// Check session validity
|
||||||
|
const halfHour = 30 * 60 * 1_000
|
||||||
|
const maxOld = Date.now() - halfHour
|
||||||
const session = this.#store.get(uuid)
|
const session = this.#store.get(uuid)
|
||||||
|
|
||||||
if (session === undefined) {
|
if (session === undefined) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (session.timestamp < this.maxAge) {
|
if (session.timestamp < maxOld) {
|
||||||
session.destroy()
|
session.destroy()
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue