且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Firebase电子邮件验证行为

更新时间:2023-12-01 18:08:58

电子邮件验证是带外进行的,除非重新加载,否则不会影响任何现有的firebase状态.如果用户验证了他们的电子邮件,则必须调用firebase.auth().currentUser.reload()来更新emailVerified属性.如果您将Firebase规则与emailVerified字段一起使用,则需要在验证后强制刷新令牌(firebase.auth().currentUser.getToken(true)).您可以使用Firebase实时数据库在电子邮件验证上设置一些标志,并在现有会话中对其进行检测以强制用户重新加载.这将需要您构建自己的自定义电子邮件验证处理程序: https://firebase. google.com/docs/auth/custom-email-handler

The email verification occurs out of band and would not affect any existing firebase states until it is reloaded. If a user verifies their email, you have to call firebase.auth().currentUser.reload() to update the emailVerified property. If you are using firebase rules with emailVerified field, you need to force a token refresh (firebase.auth().currentUser.getToken(true)) after verification. You can use the Firebase realtime database to set some flag on email verification and detect it in the existing session to force a user to reload. This would require you build your own custom email verification handler: https://firebase.google.com/docs/auth/custom-email-handler