[英]Admin panel and user login in firebase and reactjs
I want to use one login form for admin and a user in my project for react js and firebase,only the admin to be able to login and be redirected to the admin panel and the user to the user profile with,我想为管理员使用一个登录表单,在我的项目中为 react js 和 firebase 使用一个用户,只有管理员才能登录并被重定向到管理面板,用户可以使用以下方式重定向到用户配置文件,
How can i implement this?我该如何实施?
The recommended way for implementing such a role-based access control system is to use Custom Claims .实现这种基于角色的访问控制系统的推荐方法是使用自定义声明。
You will combine Custom Claims (and Firebase Authentication ) together with Firebase Security Rules.您将自定义声明(和Firebase 身份验证)与 Firebase 安全规则结合起来。 As explained in the doc referred to above:如上述文档中所述:
The Firebase Admin SDK supports defining custom attributes on user accounts. Firebase Admin SDK 支持在用户帐户上定义自定义属性。 This provides the ability to implement various access control strategies, including role-based access control, in Firebase apps.这提供了在 Firebase 应用程序中实施各种访问控制策略的能力,包括基于角色的访问控制。 These custom attributes can give users different levels of access (roles), which are enforced in an application's security rules.这些自定义属性可以为用户提供不同级别的访问权限(角色),这些权限在应用程序的安全规则中强制执行。
Once you'll have assigned to your users a Custom Claim corresponding to their user role (eg Admin or "simple" user), you will be able to:一旦您为您的用户分配了与其用户角色(例如管理员或“简单”用户)相对应的自定义声明,您将能够:
You may be interested by this article which presents "How to create an Admin module for managing users access and roles" which shows how to use Cloud Functions to assign the Claims (disclaimer, I'm the author) .您可能会对这篇介绍“如何创建用于管理用户访问和角色的管理模块”的文章感兴趣,该文章展示了如何使用Cloud Functions分配声明(免责声明,我是作者) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.