【问题标题】:Why does an anonymous user stay anonymous after successfully calling sendEmailVerification?为什么匿名用户在成功调用 sendEmailVerification 后仍然保持匿名?
【发布时间】:2020-03-30 21:03:27
【问题描述】:

使用 Javascript Firebase SDK 我基本上是这样做的:

// do the signIn
firebase.signInAnonymously()
console.lof(user.isAnonymous) // obviously: true

// determine email and send it to anon user
user.updateEmail(somebody@example.com)
user.sendEmailVerification()

// after I reload the user
user.reload()
console.log(user.emailVerified) // true
console.lof(user.isAnonymous) // false

为什么用户在成功通过验证后仍保持匿名。正确的方法是什么?

【问题讨论】:

  • 不确定您的问题是否正确,您是否尝试从匿名用户升级为具有凭据的用户?如果是这样,请尝试这里的最后一点firebase.google.com/docs/auth/web/anonymous-auth
  • 我知道。不幸的是,这对我没有帮助,因为匿名用户是特定于会话(又名选项卡)的。我不知道匿名用户和来自 signinWithEmail 的 authcred 如何在同一页面中可用。

标签: javascript firebase firebase-authentication


【解决方案1】:

无法直接验证匿名用户。匿名帐户的意义在于,用户可以拥有一个帐户,而无需用户放弃其身份。由于匿名帐户没有电子邮件地址,因此要求电子邮件验证毫无意义。您可能想检查在该调用期间是否有错误(您应该始终检查返回的 Promise 是成功解决还是因错误而被拒绝)。

如果您想将匿名帐户覆盖到可以验证的电子邮件/密码帐户,follow the instructions in the documentation。您最终将不得不致电linkWithCredential 来完成协议。

【讨论】:

  • 我的意思是,如果你给匿名用户一封电子邮件并验证它,你会期望自动升级(并且 isAnonymous === true)。 linkWithCredential 在我的情况下不可行,因为身份验证流程不同。
  • 抱歉,这不是它的工作方式。如果您有 Firebase 身份验证的功能请求,您可以将其提交给 Firebase 支持。 support.google.com/firebase/contact/support
猜你喜欢
  • 1970-01-01
  • 2022-01-21
  • 1970-01-01
  • 2018-09-10
  • 1970-01-01
  • 2021-02-17
  • 2019-06-03
  • 2020-06-16
  • 2019-02-23
相关资源
最近更新 更多