简体   繁体   English

firebase 和 reactjs 中的管理面板和用户登录

[英]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:一旦您为您的用户分配了与其用户角色(例如管理员或“简单”用户)相对应的自定义声明,您将能够:

  • Adapt your Security Rules according to the claims;根据声明调整您的安全规则;
  • Get the Claim in your front-end and act accordingly (eg redirected to the admin panel or to the user profile) 在您的前端获取声明并采取相应措施(例如重定向到管理面板或用户配置文件)

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.

相关问题 Reactjs 用户认证 firebase - Reactjs user Authentication with firebase 管理员和用户从反应和后端的同一登录页面登录我正在使用 firebase - Admin and user login from same login page in react and back end i am using firebase ReactJS/Firebase:我如何让用户删除自己? - ReactJS/Firebase : How do I let a user delete themselves? 为什么数据未显示来自 ReactJs 中的 firebase 用户的数据? - Why data is not showing getting from firebase user in ReactJs? 管理员使用 Firebase 手动批准/拒绝用户注册 - Manual approval / rejection of user registration by admin using Firebase 如何在登录用户通过 Facebook 在 firebase for ios swift 登录后进行检查? - How to check after login user is login through Facebook in firebase for ios swift? Firebase Android - 如何以不同用户身份登录(使用 Google 登录后) - Firebase Android - how to login as different user (after signing in with Google) 创建用户登录/注册错误(Angular、Ionic 和 Firebase) - Create user Login / Registration Error (Angular, Ionic and Firebase) 在使用 reactjs 发送 POST 请求之前,我如何等待 firebase 检查用户是否有效? - how can i wait for firebase to check the user is valid before sending a POST request with reactjs? 使用 firebase 管理员与 REST - Use firebase admin with REST
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM