Firebase 阻止在电子邮件验证之前创建帐户 [英] Firebase Prevent Creating Account Before Email Verification

查看:25
本文介绍了Firebase 阻止在电子邮件验证之前创建帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含用户使用电子邮件登录的 android 项目.但问题是这个.当我创建测试帐户时,它会立即出现在 Firebase 身份验证部分,无需验证.但它也会发送验证邮件.我想防止这种情况.因为例如,如果有人输入我的电子邮件地址,但他们无法点击验证链接,因为它涉及到我的邮箱.但是,当我尝试使用普通邮件地址应用程序进行注册时,它会崩溃并且不再发送验证邮件.我的目标是防止在没有验证的情况下创建帐户并在第二次或第三次或任何尝试时发送验证电子邮件.

I am working on an android project that includes user sign-in with email. But the problem is this. When I create test account it immediately appears in the firebase authentication section without verification. But it also sends verification mail. I want to prevent this. Because for example if somebody enters my email address and they can not click verification link because it comes to my mailbox. But when I try to sign-up with my normal mail address app crashes and it is not sending verification mail again. My goal is to prevent account creating without verification and sending verification email on second or third or whatever try.

推荐答案

如果您只需要经过验证的帐户,那么您应该通过安全规则强制执行.

If you require only verified accounts, then you should enforce it via security rules.

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

如果您不喜欢该帐户被创建和丢弃,您可以使用 Firebase Admin SDK 以在一段时间后清理未经验证的帐户.

If you don't like that the account was created and discarded, you can write an offline job using the Firebase Admin SDK to clean up unverified accounts after some time.

您无法在创建帐户之前验证电子邮件.

You can't verify the email before creating the account.

这篇关于Firebase 阻止在电子邮件验证之前创建帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆