fix(SW-2210): Checking for session inside MyPagesMenu to sync session state
This commit is contained in:
committed by
Michael Zetterberg
parent
7b76e351d9
commit
d827bf04d0
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user