2

I have an issue that when user clicks in the verification link, the popup appears and everything goes well. However if user is logged in, the state is not being updated.

Im displaying a huge banner with text: Your email is not verified yet

But still after verifying the mail it still appears, because:

fire.auth().onAuthStateChanged((user) => {

is not being fired.

Is there a way to listen to verification event, so I can update the app after?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Patrickkx
  • 1,740
  • 7
  • 31
  • 60
  • Email verification happens out of band, so `onAuthStateChanged` is not automatically called. You cannot really detect it synchronously, but there are some workarounds mostly by forcing a token refresh at the right moment. See: https://stackoverflow.com/a/50900115, https://stackoverflow.com/a/50900115, https://stackoverflow.com/a/53509219, https://stackoverflow.com/a/54594760 – Frank van Puffelen May 27 '20 at 20:23

1 Answers1

0

It depends on where you have this section of code. firebase.auth().onAuthStateChanged(function(user) {});

I would try to put it in the constructor of the firebase model(if you have a class for that). OR right after you do firebase.initializeApp(firebaseConfig);

Usually this will be put in at the entry point of the app.

user3900196
  • 457
  • 2
  • 6
  • 18