Update the email verification status without reloading page

五迷三道 提交于 2021-01-13 09:13:54

问题


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();
  }
});

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.

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?


回答1:


The change in email verification status happens on the Firebase servers. It is not automatically pushed to the client.

On the client you can reload the user data to pick up any changes, by calling User.reload().

Also see:

  • Firebase: Observe email verification status in real time
  • Auth.auth().currentUser?.reload() doesn't refresh currentUser.isEmailVerified


来源:https://stackoverflow.com/questions/53508364/update-the-email-verification-status-without-reloading-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!