简体   繁体   English

如何在ASP.NET Identity中为帐户创建和身份验证在用户名和密码中添加一个字段?

[英]How can I add one more field to username and password for account creation and authentication in ASP.NET Identity?

I am trying to register and authenticate users who need more than username and password for authentication because their username is their school registration number and we are enrolling many schools on our platform where registration number may clash and wouldn't be unique anymore except we distinguish it with School Id ... 我正在尝试注册和认证需要身份验证的用户,因为他们的用户名是他们的学校注册号,并且我们需要在用户名和密码之外进行身份验证,而且我们正在平台上注册许多学校,注册号可能会发生冲突,并且不再唯一,除非我们将其区别开与学校ID ...

For instance, when searching for the user within the model instead of using this 例如,当在模型中搜索用户而不是使用该用户时

    var user = UserManager.Find(model.UserName, model.Password);

We use 我们用

    var user = UserManager.Find(model.UserName, model.Password, model.SchooId);

You need to create a new model that inherits from IdentityUser: 您需要创建一个继承自IdentityUser的新模型:

public class ApplicationUser : IdentityUser
{
    //add more attributes
    public string SchoolID { get; set; }

}

暂无
暂无

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

相关问题 ASP.NET MVC API-使用用户名,密码和另一个字段进行身份验证 - ASP.NET MVC API - Authentication with username, password and one other field ASP.NET身份用户名(如何添加您自己的验证)? - ASP.NET Identity UserName (how to add your own verification)? 如何向 ASP.NET 上的帐户添加不同的属性? - How can I add different attributes to the account on ASP.NET? 如何使ASP.NET身份帐户控制器中的方法返回我自己的错误消息? - How can I make a method in ASP.NET identity account controller return my own error message? 如何使用身份向 ASP.NET 核心最小 API 添加身份验证,但不使用 Azure? - How do I add authentication to an ASP.NET Core minimal API using Identity, but without using Azure? ASP.NET 核心。 如何在没有身份用户帐户的情况下创建身份验证 cookie? - ASP.NET Core. How can i create an auth cookie without an identity user account? 如何重写SHA1制作的密码哈希(在ASP.NET身份中)? - How can I rewrite password hash made by SHA1(in ASP.NET Identity)? 如何在登录ASP.net Identity之前验证用户的用户名和密码? - How to validate username and password of user before log in in ASP.net Identity? 通过表单身份验证ASP.NET MVC页创建帐户 - Account creation via Form authentication ASP.NET MVC page 如何在没有身份的asp.net MVC中实现自定义身份验证/授权? - How can I implement custom authentication/authorization in asp.net MVC without Identity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM