[英]What is the best way to keep the User's Lockout status in ApplicationUser?
I want to save the user's lockout status in my ApplicationUser (inherited from IdentityUser) in Asp.Net Mvc (Core or NetFramework), so which implementation is better from the design perspective?我想在 Asp.Net Mvc(Core 或 NetFramework)中的 ApplicationUser(继承自 IdentityUser)中保存用户的锁定状态,那么从设计角度来看,哪种实现更好?
class ApplicationUser: IdentityUser
{
// ...
public bool IsAcitve {get; set;}
public UserLockoutReason LockoutReason {get; set; }
}
enum UserLockoutReason
{
NotLocked,
LockedByAdmin,
MaximumWrongPasswordAttemptsReached,
...
}
class ApplicationUser: IdentityUser
{
// ...
public UserActiveStatus ActiveStatus {get; set; }
}
enum UserActiveStatus
{
Active,
LockedByAdmin,
MaximumWrongPasswordAttemptsReached,
...
}
ps: This design is going to be as an UserManagement's part to our IdentityProvider, so it's is so important to us to implement the best way we can ps:这个设计将成为我们 IdentityProvider 的 UserManagement 的一部分,所以对我们来说实现最好的方式非常重要
I would go in this direction:我会在这个方向上 go :
class ApplicationUser: IdentityUser
{
// ...
public UserActiveStatus ActiveStatus {get; set; }
}
enum UserActiveStatus
{
Active,
LockedByAdmin,
MaximumWrongPasswordAttemptsReached,
...
}
Since the ActiveStatus
is the final information that you will need for the user, there will be need to branch of user.IsActive
in if-else statements, and then getting the LockoutReason
in case it's locked account won't be neccesary由于
ActiveStatus
是您需要为用户提供的最终信息,因此需要在 if-else 语句中对user.IsActive
进行分支,然后获取LockoutReason
以防帐户被锁定
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.