How would I be able to check in real time if the user verified his email?
My flow is like this:
Now I would like to:
For this I would need a method that fetches the user data from firebase. Usually you just use the onAuthStateChanged callback to get userdata but I need to explicitly fetch current data.
How would I do that?
Found a way!
firebase.auth().currentUser.reload()
will fetch current user data. So all I have to do is this:
this.checkForVerifiedInterval = setInterval(() => {
firebase.auth()
.currentUser
.reload()
.then(ok => {
if (firebase.auth().currentUser.emailVerified) {
this.props.history.push("/verification-email-verified")
window.Materialize.toast("Email verified.", 3000)
clearInterval(this.checkForVerifiedInterval)
}
})
}, 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