NextAuth middleware authorized callback
Unanswered
Sawfly parasitic wasp posted this in #help-forum
Sawfly parasitic waspOP
Hello,
I have an authorized callback in my withAuth middleware that is in charge of redirecting the user to the SignIn page if the token expires :
It's working fine, however, when checking the session with useSession, I can see that the session is not destroyed. I can still see "authenticated" in the status, and the user info. How can I destroy the user session in that case ?
I have an authorized callback in my withAuth middleware that is in charge of redirecting the user to the SignIn page if the token expires :
export default withAuth(
{
callbacks: {
authorized: ({ token }) => {
const expiryTime = token?.expiryTime as number;
const isValid = new Date().getTime() < expiryTime;
return isValid;
},
},
pages: {
...pagesOptions,
},
}
);It's working fine, however, when checking the session with useSession, I can see that the session is not destroyed. I can still see "authenticated" in the status, and the user info. How can I destroy the user session in that case ?