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.
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 ofcheckAuth
.see note in: https://firebase.google.com/docs/auth/web/manage-users#get_the_currently_signed-in_user