问题描述
我的注册流程如下:
用户填写详细信息并注册(发送验证电子邮件)
User fills out details and signs up (gets send verification email)
此用户登录后,但看到要求进行电子邮件验证的屏幕
After this user is logged in, but sees a screen asking to for email verification
用户验证他们的电子邮件并返回应用
User verifies their email and goes back to app
在这个阶段,如何在不注销用户的情况下获取具有 emailVerified
字段的新用户数据?
At this stage how can I get new user data that will have emailVerified
field without logging user out?
我希望 auth().onAuthStateChanged
在 emailVerified
更改为 true 后被触发,但这不会发生,我也无法在 firebase 文档中找到任何刷新功能手动获取这些数据.
I expected auth().onAuthStateChanged
to be fired once emailVerified
changes to true, but that does not happen, nor can I find any refresh function in firebase docs to get this data manually.
我可以获得 emailVerified
的新值的唯一方法是注销并重新登录,但最好避免这种情况.
Only way I can get that new value for emailVerified
is by loging out and loging back in, but ideally would like to avoid this.
更新:这是使用 JavaScript SDK
update: this is using JavaScript SDK
推荐答案
基于android我做的
Based on android I did
firebase.auth().currentUser.reload().then(() => {
console.log(firebase.auth().currentUser)
})
这将返回有关用户的更新信息,由于某种原因,我在文档中的任何地方都找不到此信息
this returns updated information about the user, I couldn't find this anywhere in the docs for some reason
这篇关于我可以在不注销的情况下获得更新的 emailVerified 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!