correction nextauth
This commit is contained in:
parent
6321d1623f
commit
cdb93a30a0
@ -281,7 +281,7 @@ export const authOptions: NextAuthOptions = {
|
|||||||
return refreshedToken;
|
return refreshedToken;
|
||||||
},
|
},
|
||||||
async session({ session, token }) {
|
async session({ session, token }) {
|
||||||
// If session was invalidated or tokens are missing, throw error to trigger sign out
|
// If session was invalidated or tokens are missing, return null to sign out
|
||||||
if (token.error === "SessionNotActive" ||
|
if (token.error === "SessionNotActive" ||
|
||||||
token.error === "NoRefreshToken" ||
|
token.error === "NoRefreshToken" ||
|
||||||
!token.accessToken ||
|
!token.accessToken ||
|
||||||
@ -292,9 +292,11 @@ export const authOptions: NextAuthOptions = {
|
|||||||
hasRefreshToken: !!token.refreshToken
|
hasRefreshToken: !!token.refreshToken
|
||||||
});
|
});
|
||||||
|
|
||||||
// Throw error to make NextAuth treat user as unauthenticated
|
// Return null to make NextAuth treat user as unauthenticated
|
||||||
// This will trigger automatic redirect to sign-in page
|
// This will trigger automatic redirect to sign-in page
|
||||||
throw new Error(token.error || "SessionInvalidated");
|
// The client-side code will detect session invalidation by checking for
|
||||||
|
// session cookie existence when status is unauthenticated
|
||||||
|
return null as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For other errors, throw to trigger error handling
|
// For other errors, throw to trigger error handling
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user