[英]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.