Android Firebase电子邮件验证 [英] Android Firebase Email Validation

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

问题描述

我正在开发一个Firebase应用程序,我必须使用Firebase提供的电子邮件注册方法将用户注册到应用程序。我几乎做了电子邮件验证和这样的事情,但我遇到的一个问题是,如何验证输入的电子邮件地址?



通过验证,我并不意味着它是否为正确的电子邮件形式,例如 blab@blabla.com 模式,例如 Iamsomething@gmail.com 是一个无效的电子邮件,无法得到电子邮件验证,虽然它是完全正常的电子邮件模式。



我想确保无效的电子邮件没有注册到身份验证数据库摆在首位。如何解决这个问题?解决方案

您无法阻止用户使用电子邮件帐户在Firebase身份验证中创建帐户,这就是为什么你会在你的应用程序中实现电子邮件验证:你可以阻止这些用户访问其他资源。例如,您可以确保只有拥有经过验证的电子邮件地址的用户才能访问Firebase数据库:

  {
rules:{
.read:auth.token.email_verified == true
}
}

看到我的答案在这里的扩展版本:如何将Firebase数据库锁定到特定(电子邮件)域中的任何用户?


I am developing an app with Firebase and I have to register users to the app using email registration method provided by Firebase. I pretty much did well on Email verification and such things, but one problem, I'm encountering is that "how to validate" entered email address?

By validation, I don't mean if its a correct email form, such as blab@blabla.com pattern, for example Iamsomething@gmail.com is an invalid email which cant get email verification, although it is perfectly fine in terms of email pattern.

I want to make sure that invalid emails are not registered to authentication database in the first place. How can I solve this problem?

解决方案

You cannot prevent users from creating an account on Firebase Authentication with an email account they don't own.

That is precisely why you'd implement email verification in your app: to you can prevent those users from accessing other resources. For example, you can ensure that only users with a verified email address can access the Firebase Database with:

{
  "rules": {
    ".read": "auth.token.email_verified == true"
  }
}

See my answer here for an extended version of that: How do I lock down Firebase Database to any user from a specific (email) domain?

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

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