Skip to content

fix: clear auth state immediately on removeUser#1948

Open
SergioChan wants to merge 1 commit intoauthts:mainfrom
SergioChan:fix/issue-751-removeuser-state
Open

fix: clear auth state immediately on removeUser#1948
SergioChan wants to merge 1 commit intoauthts:mainfrom
SergioChan:fix/issue-751-removeuser-state

Conversation

@SergioChan
Copy link

Closes/fixes #751

Summary

  • dispatch USER_UNLOADED immediately after removeUser() resolves so auth context clears even when UserUnloaded events are not emitted by the runtime/mock environment
  • keep existing onRemoveUser callback behavior unchanged
  • add a regression test that starts from an authenticated state and verifies user + isAuthenticated are cleared right after removeUser()

Testing

  • npm test -- AuthProvider.test.tsx

Checklist

  • This PR makes changes to the public API
  • I have included links for closing relevant issue numbers

@@ -301,6 +301,9 @@ export const AuthProvider = (props: AuthProviderProps): React.JSX.Element => {
const removeUser = React.useCallback(async () => {
if (!userManager) unsupportedEnvironment("removeUser");
await userManager.removeUser();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sound like a test issue you are trying to fix.
await userManager.removeUser(); calls at the end await this._events.unload();, which will trigger the USER_UNLOADED event in this library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

revokeTokens and removeUser doesn't deauthenticate the user.

2 participants