Open
Description
Hi,
I've added the signout process on a Nuxt3 app last week and even if it works, I'm still not sure if I did it the right way or not.
Note that I did not code the login part and that I read thoroughly this discussion before starting to dev nextauthjs/next-auth#3938
First I modified my server/api/auth/[...].ts
to modify the callbacks session
and jwt
to make the IdToken available.
Then to logout it's quite easy :
const { data: authData } = useAuth();
const idToken = (authData.value as any)?.idToken;
const redirectUrl = runtimeConfig.public.AUTH_ORIGIN;
const endSessionUrl = `${runtimeConfig.public.AUTH_ISSUER_IDSERVER}/connect/endsession?id_token_hint=${idToken}&post_logout_redirect_uri=${redirectUrl}`;
await signOut({ redirect: false });
window.location.href = endSessionUrl;
So I call signOut
first with no callback and end with a redirect to the endsession which will redirect me to my signin page if all goes well.
Thanks in advance.