如何创建角色和管理用户?

发布于 2025-01-02 04:56:04 字数 272 浏览 7 评论 0原文

在我的项目中,我需要定义 3 个角色:

  1. SuperAdmin
  2. Admin
  3. RegisteredMembers

我还有一个名为“Users”的表,用于存储以下信息:

  1. fristName
  2. lastName
  3. 生日
  4. 用户名
  5. 密码 。 。 。 ?

当用户尝试登录网站时,如何使角色识别哪个用户对应哪个角色

in my Project i need to define 3 roles :

  1. SuperAdmin
  2. Admin
  3. RegisteredMembers

I also have Table which named "Users" that stores information such as:

  1. fristName
  2. lastName
  3. Birthday
  4. Username
  5. Password
    .
    .
    .
    and etc

How can i make Roles recognize which user is for which Role when users try to log on to website?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

森罗 2025-01-09 04:56:04

首先,创建Users 表只是第一步。您还需要一个Role表和一个UserRole多对多关系表来存储哪个用户属于哪个角色(在一个简单的场景中)。

这是整个概念的数据库部分。

然后,在代码方面...因为您提供的表格与 AspNetMembership 您还需要实现 自定义会员提供程序自定义角色提供程序< /a> 并且可能是自定义会员用户

First of all you creating a Users table is just the first step. You also need a Role table and a UserRole many-to-many relationship table to store which user belongs to which role(In a simple scenario).

That's for the database part of the whole concept.

Then, on the code side...since you're providing different tables than the ones in the AspNetMembership you need to also implement a custom membership provider, custom role provider and presumably a custom membership user.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文