resulturan / refine-firebase

MIT License
43 stars 22 forks source link

Use an observer to check auth status awaiting firebase initialization #4

Closed samelhusseini closed 1 year ago

samelhusseini commented 1 year ago

If checkAuth is called before firebase has finished initializing, this.auth?.currentUser is null, even if a user is currently logged in, resulting in a redirection to the login page in all cases.

This change uses an observer (onAuthStateChanged) to await firebase initialization before determining the result of checkAuth.

see note in: https://firebase.google.com/docs/auth/web/manage-users#get_the_currently_signed-in_user

resulturan commented 1 year ago

Thanks for your contribution.