无需重新加载页面即可更新电子邮件验证状态 [英] Update the email verification status without reloading page
问题描述
在我的网络应用程序中注册后,我将用户重定向到一个页面,在那里他被告知要验证他的电子邮件.一旦他这样做了,我想自动检测verificationStatus的变化,然后更改页面.类似的东西.
After registering in my web app, i redirect the user to a page, where he is told to verify his email. Once he has done that, i want to automatically detect the change of the verificationStatus and then change the page. Something along those lines.
auth.user.subscribe(user => {
if (!!user && user.emailVerified === true) {
this.redirectToLogin();
}
});
我找不到任何方法来检测 emailVerified 状态的变化,所以我想,也许有一个间隔运行,不时更新用户数据,但我找不到如何刷新来自 Firebase 身份验证的用户数据.
I couldn't find any way to detect changes of the emailVerified status, so I thought, maybe have an interval runnning that is updating the user data every now and then, but I couldn't find a way how to refresh the user data from firebase authentication.
有没有办法在不重新加载/刷新页面的情况下更新用户数据?我必须刷新 authState 吗?如果可能,我该怎么做?
Is there a way to update the user data without reloading/refreshing the page? Do i have to refresh the authState? If possible, how can i do that?
我想做的事,甚至可能吗?
Is what I want to do, even possible?
推荐答案
电子邮件验证状态的更改发生在 Firebase 服务器上.它不会自动推送到客户端.
The change in email verification status happens on the Firebase servers. It is not automatically pushed to the client.
在客户端上,您可以通过调用 User.reload()
.
On the client you can reload the user data to pick up any changes, by calling User.reload()
.
另见:
这篇关于无需重新加载页面即可更新电子邮件验证状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!