After a user signs up, they are sent a confirmation link to their email address through Firebase. If the account is not verified, the user isn't able to interact with anything on the app. Once the account is verified, the React state changes, enabling elements on the app so the user can begin interaction. Is there any way to listen to a change to the current user's auth object so that the state can change after the user clicks the confirmation link?
I tried setting up a timer like this, but it doesn't actually check currentUser.emailVerified
in real time:
timer.addEventListener('secondsUpdated', () => {
this.setState({ timer: timer.getTimeValues().seconds });
this.forceUpdate();
console.log(auth.currentUser.emailVerified);
auth.onAuthStateChanged(user => {
console.log(user.emailVerified);
});
});
Both logs return false
even after the user clicks the confirmation link. I don't want to force the user to have to refresh the page in order for the elements to be enabled, if their account is verified. Any ideas?