In Firebase 2, I was able to do a synchronous check to check if the user was logged in, for example:
if (!ref.getAuth()) ..go to login page else ..show page
I can access the currentUser state using firebase.auth().currentUser , so I tried to do:
if (!firebase.auth().currentUser) ..go to login page else ..show page
The problem is that it is always initially zero, so it is redirected to the login page, and then onAuthStateChanged happens after a few seconds and the user logs in.
Is there another way to check this synchronously? Or else is there a promise that I can listen to so that I can show the bootloader or something else? Thanks.
source share