Logout and then log back in with different user

Hi,

I have incorporated the following sample into my application: https://github.com/auth0-samples/auth0-react-samples/tree/master/05-Token-Renewal

The sample has this:
logout() {
// Clear access token and ID token from local storage
localStorage.removeItem(‘access_token’);
localStorage.removeItem(‘id_token’);
localStorage.removeItem(‘expires_at’);
localStorage.removeItem(‘scopes’);
this.userProfile = null;
clearTimeout(this.tokenRenewalTimeout);
// navigate to the home route
history.replace(‘/home’);
}

This just removed the information from local storage so my application thinks the user is not logged on. However, when I click to login again, it logs me into whatever account I was using before. How would I modify the sample so that a proper logout occurs and I can log in again as a different user (or through a different provider)?

Thanks!

You need to call the logout endpoint.

1 Like