Skip to content

[firebase-auth] currentUser property keeps the user object after signing out #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
canmertc opened this issue Mar 21, 2022 · 0 comments

Comments

@canmertc
Copy link
Contributor

firebase().auth().currentUser property stores the User object on a successful sign-in as expected. But it keeps storing the user object after signing out. currentUser getter returns the first signed-in user even after signing in to another user account.

⚠️ Because of firebase().auth().currentUser.getIdToken() returns the first user's token; It causes the 2nd user to use the first user's id token when hitting API endpoints.

Steps to reproduce

  1. Sign in (Account A)
console.log(firebase().auth().currentUser) // User (Account A)
console.log(firebase().auth().native.getCurrentUser()) // [Android] Native user (Account A)
console.log(firebase().auth().native.currentUser) // [IOS] Native user (Account A)
  1. Sign out (Account A)
console.log(firebase().auth().currentUser) // Still has the user data of Account A [BUG]
console.log(firebase().auth().native.getCurrentUser()) // [Android] null
console.log(firebase().auth().native.currentUser) // [IOS] null
  1. Sign in (Account B)
console.log(firebase().auth().currentUser) // Still has the user data of Account A [BUG]
console.log(firebase().auth().native.getCurrentUser()) // [Android] Native user (Account B)
console.log(firebase().auth().native.currentUser) // [IOS] Native user (Account B)
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

No branches or pull requests

1 participant