fix(SW-2210): Checking for session inside MyPagesMenu to sync session state

This commit is contained in:
Erik Tiekstra
2025-04-16 13:05:57 +02:00
committed by Michael Zetterberg
parent 7b76e351d9
commit d827bf04d0
3 changed files with 15 additions and 3 deletions

View File

@@ -2,7 +2,6 @@ import type { Session } from "next-auth"
export function isValidClientSession(session: Session | null) {
if (!session) {
console.log("No session available (user not authenticated).")
return false
}
if (session.error) {
@@ -10,5 +9,14 @@ export function isValidClientSession(session: Session | null) {
return false
}
if (session.token.error) {
console.log(`Session token error: ${session.token.error}`)
return false
}
if (session.token.expires_at && session.token.expires_at < Date.now()) {
console.log(`Session expired: ${session.token.expires_at}`)
return false
}
return true
}