如何做好手柄登录,注销 [英] How to do handle login-logoff

查看:146
本文介绍了如何做好手柄登录,注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在用新的用户认证系统的 Asp.Net身份的在我的项目。我有一个情况我要存储3种类型的用户数据库,即:




  • 学生

  • 教师

  • 管理



现在所有这些3有有单独的表中包含了每个不同的信息其中之一。我想Asp.Net身份来处理他们的登录,注销和密码为 - 维持每种类型的用户。



任何人都可以请指导我,我该如何处理这种情况呢?


解决方案<概述/ DIV>

您需要一个继承结构是这样的:

 公共抽象类用户{} 
公共类学生:用户{}
公共班主任:用户{}
公共类管理:用户{}

其中用户基类适用于身份验证的所有必要的信息。这样,您可以处理所有类型的用户以统一的方式。



至于数据库,有不同的策略,多态如何被处理(例如表每个具体类型的)。


I am using the new user authentication system Asp.Net Identity in my project. I have a situation where I have to store 3 types of users in database i.e.:

  • Student
  • Teacher
  • Admin

Now all these 3 have there separate table contains different information about each one of them. I want Asp.Net Identity to handle their login, logoff and password maintance for each type of user.

Can anyone please guide me with the overview of how can I handle this situation?

解决方案

You need an inheritance structure like this:

public abstract class User {}
public class Student : User {}
public class Teacher : User {}
public class Admin : User {}

where the User base class holds all necessary info for authentication. This way, you can handle all types of Users in a unified way.

Regarding the database, there are various strategies how such polymorphism can be handled (e.g. Table per Concrete Type).

这篇关于如何做好手柄登录,注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆