Firebase - How to detect / observe when a Firebase user checked his email, for example onAuthStateChanged

I understand that for user email authentication I can use

firebase.auth().onAuthStateChanged((user) => {
    console.log(user["emailVerified"]);
})

However, my problem is that I want to monitor / listen and redirect to another page whenever a user checks his email address in his inbox.

Based on my testing, onAuthStateChanged starts when the user logs in, updates his profile and logs out, but does not start when the user checks his email address in his inboxes.

In any case, can I detect when the user is verified and automatically redirected to another page?

+5
source share
2 answers

I managed to get it to work through the setInterval function, which checks the userSenderVerified property every second with the following:

setInterval(function() {
  firebase.auth().currentUser.reload();
  if (firebase.auth().currentUser.emailVerified) {
      console.log("Email Verified!");
      this.navCtrl.setRoot(HomePage);
  }
}, 1000);
+2
source

Sadly, Firebase does not solve this problem, in the end I checked the emailVerified checkbox on the Firestore document to synchronize the state between open tabs.

0
source

Source: https://habr.com/ru/post/1666212/


All Articles