简体   繁体   English

ASP.NET身份:处理多种类型的用户

[英]ASP.NET Identity: handling more than one type of users

I am new to ASP.NET Identity. 我是ASP.NET Identity的新手。

I have two type of users 我有两种类型的用户

  1. Student 学生
  2. Teacher 老师

I need get some unique information from each type of user based on theirs type. 我需要根据用户的类型从每种类型的用户那里获取一些独特的信息。

student: username, password, email, address, telephone, age,... 学生:用户名,密码,电子邮件,地址,电话,年龄,...

teacher: username, password, email, address, category, price, description,... 老师:用户名,密码,电子邮件,地址,类别,价格,说明,...

I thinking about role-based authentication. 我考虑基于角色的身份验证。 is it the best solution? 这是最好的解决方案吗? Is it a good idea to store both user types' information in one table (ASPNetUser table)? 将两种用户类型的信息存储在一个表(ASPNetUser表)中是个好主意吗? or there is another way to store them in sperate tables? 还是有另一种方法将它们存储在单独的表中?

Claim based authorization is suitable for your scenario. 基于声明的授权适合您的方案。 Check this link below for claim based authorization. 检查下面的此链接以获得基于声明的授权。

https://www.future-processing.pl/blog/introduction-to-claims-based-authentication-and-authorization-in-net/ https://www.future-processing.pl/blog/introduction-to-claims-based-authentication-and-authorization-in-net/

With claim based authorization you can store different information for different type of user. 使用基于声明的授权,您可以为不同类型的用户存储不同的信息。

For student you can store information as claim. 对于学生,您可以根据要求存储信息。 For teacher you can store different information as claim. 对于老师,您可以根据要求存储其他信息。

However you will need to store this information in separate table. 但是,您将需要将此信息存储在单独的表中。 You can create separate User metadata table where in you can store this information and separate table to store login credential. 您可以创建单独的用户元数据表,可以在其中存储此信息,也可以创建单独的表以存储登录凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM