如何使用Firebase限制用户使用特定域来注册我的应用 [英] How to restrict user to use specific domain to sign up my app using firebase

查看:54
本文介绍了如何使用Firebase限制用户使用特定域来注册我的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用Ionic 2和Firebase为我的大学开发一个应用程序.因此,问题在于,除非他们使用特定的域,例如(@ ukm.edu.my),否则如何限制用户注册?这是为我的大学准备的,我不希望其他人使用此应用.因此,没有该特定电子邮件域的任何人都无法注册我的应用.

I'm currently developing an app for my university using Ionic 2 and Firebase. So, the problem is how to restrict user from signing up unless they're using specific domain eg.(@ukm.edu.my)? It's for my university, I don't want anyone else to use this app. So, anyone without that specific email domain can't sign up for my app.

据我了解,Firebase数据库规则仅影响授权.那么,如何设置身份验证规则?

From what I've read, Firebase database rules only affect authorization. So, how to setup rules for authentication?

推荐答案

您无法使用Firebase提供的功能来做到这一点.

You can't do it with what Firebase provides.

您只能通过添加一条规则来限制对数据库的访问,该规则指出在特定域中拥有电子邮件的用户可以访问它.

You can only restrict access to the database adding a rule stating that users with email in a specific domain can access it.

{
  "rules": {
    ".read": "auth.token.email.endsWith('@example.com')",
    ".write": "auth.token.email.endsWith('@example.com')",
  }
}

这篇关于如何使用Firebase限制用户使用特定域来注册我的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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