首页 > 解决方案 > how to set 2 types of user for a certain app

问题描述

I wanna to create an app that has 2 types of users first type is admin: that has Authority to add info and manage the app second type is the customer and every one has a different options and screens now if I used firebase with specific login with facebook, it will offer only one type of user so how I can use the both types of users authinication ( where I begin to search ?? ) and if want to put an IF method in the code of the app ( if the admin input a specific password it will give him the access to the admin app , is this method dangerous or less security ?

标签: javaandroidfacebookfirebase-authentication

解决方案


您正在寻找自定义声明

您可以分配给custom claims用户帐户,然后您应该使用custom claims文档中指定的帐户来区分该用户是否具有所需custom claims的“权限”,以便执行该特定操作,无论是对 Firestore 还是对存储的读/写。

在应用程序中,您可以使用这些自定义声明来选择要为登录用户显示的 UI。

UI 本身应该只是一个骨架,您应该始终使用来自可信来源(服务器、firestore、存储、云功能)的数据填充 UI,以验证完整性,custom claims因为恶意可以编辑您的代码以获取访问用户界面。


推荐阅读