I understand that to check if the user's email is verified, I can use
firebase.auth().onAuthStateChanged((user) => {
console.log(user["emailVerified"]);
})
However my problem is, I want to observe/listen and redirect to another page whenever the user verified their email address on their inbox.
Based on my testing, onAuthStateChanged is triggered when user logged in, updated their profile, and logged out, but is not triggered when the user verified their email address on their inbox.
Is there anyway I can detect when the user is verified and automatically redirect to another page?
If the user login with a custom "email/password" you don't know anything else about that user (apart from the unique user id). If a user login with Facebook, or with Google sign in, you can get other information like the profile picture url. It is explained here: firebase.google.com/docs/auth/android/… .
I managed to make it work through a setInterval function which checks the user's emailVerified 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With