【问题标题】:Firebase Auth API email verification JavaScriptFirebase Auth API 电子邮件验证 JavaScript
【发布时间】:2018-12-15 03:56:09
【问题描述】:

我为我的应用程序和 firebase 使用 nuxt (vue) 来验证我的用户。为此,我使用 axios 发送了一个 post 请求。到目前为止,一切都很好。我收到了一些凭据的回复。然后我用 axios 发送另一个帖子请求,向用户发送验证电子邮件。这也有效。但我不知道用户通过单击链接验证电子邮件地址的信息保存在哪里。所以我不能把它作为我的身份验证过程的条件。

如果我在没有验证电子邮件的情况下使用我的电子邮件和密码登录,我也不会收到错误消息。

https://firebase.google.com/docs/reference/rest/auth/#section-create-email-password

https://firebase.google.com/docs/reference/rest/auth/#section-send-email-verification

非常感谢您提前提供的帮助。

【问题讨论】:

    标签: firebase firebase-authentication email-verification


    【解决方案1】:

    如果您不验证电子邮件,Firebase 不会阻止访问,因为许多应用程序不需要这样做。您可以通过您的安全规则强制执行此操作。示例:

    "$uid": {
      ".write": "auth.token.email_verified === true && auth.uid === $user",
      ".read": "auth.token.email_verified === true && auth.uid === $user"
    }
    

    已验证用户的 ID 令牌将包含设置为 true 的 email_verified。 Firebase Auth 将在用户单击电子邮件验证链接时存储该值。要在用户身上检测到这一点,您需要 user.reload()user.emailVerified 设置为 true。要强制 ID 令牌获取这些更改,您可以强制刷新令牌 user.getIdToken(true)

    【讨论】:

    • 我收到Unknown variable '$user'。你把这些规则放在哪里了?
    猜你喜欢
    • 2022-01-24
    • 1970-01-01
    • 2017-02-20
    • 2019-11-25
    • 2020-03-21
    • 2017-07-30
    • 2017-05-30
    • 2020-07-16
    相关资源
    最近更新 更多