I’m trying to implement a function that logs out from both the application session layer and the Auth0 session layer.
I’m using Auth0 Vue SDK.
With the logout implementation below, only the application session was cleared, leaving the Auth0 session intact. As a result, if the user reopened the universal login screen, they would be automatically logged in, which is a critical flaw.
await auth0.logout({
logoutParams: {
returnTo: redirectUrl(),
},
});
I referred to this issue and this documentation.
const logoutUrl = `https://MY_DOMAIN/v2/logoutreturnTo=MY_LOGIN_PAGE_URL&client_id=MY_CLIENT_ID`
await auth0.logout({
openUrl: () => {
window.location.replace(logoutUrl);
},
});
However, after logging out, the user is redirected to a different page than the URL specified by returnTo
.
That different page is the callback URL set as the redirect destination after login.
const auth0 = createAuth0({
authorizationParams: {
redirect_uri: `https://.../callback/`, // ← This page!
},
});
After redirected to callback page, subsequently the user is redirected to the returnTo
page.
This means there’s one unexpected redirect in the logout process.
Application page → /logout endpoint → callback URL → returnTo page
I expect this kind of process.
Application page → /logout endpoint → returnTo page
( Strangely, sometimes it directly redirects to the returnTo
page. It behaves as I expected, but it only happens occasionally. )
Is this an expected behavior, or a bug?