Answered by:
Admins unlock an account.

Question
-
User323983933 posted
Ok, I have seen the code to enable retry lockouts,
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { ... SignInManager.UserManager.DefaultAccountLockoutTimeSpan = new TimeSpan(1, 0, 0); SignInManager.UserManager.MaxFailedAccessAttemptsBeforeLockout = 5; //5 was default var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: true);
now I want to put a link on the user manager screen that
- only appears if a user is Retry Locked Out. (Somehow read the ASPNetUser from the ApplicationUser and check the lockout status)
- Executes the await UserManager.ResetAccessFailedCountAsync(userId); command when clicked.
the only problem I am having is that the framework has created so many levels of obfuscation that I cant see how to get the lockout status of an "ApplicationUser"
Monday, May 23, 2016 6:49 PM
Answers
-
User527778624 posted
Hi,
only problem I am having is that the framework has created so many levels of obfuscation that I cant see how to get the lockout status of an "ApplicationUser"Try this code:
if (UserManager.IsLockedOut(user.Id)) //where user is ApplicationUser and UserManager is ApplicationUserManager.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 24, 2016 6:30 AM -
User1724605321 posted
Hi some_yahoo ,
In ASP.NET Identity 2 , you could use below code to if user is locked-out :
if (await UserManager.IsLockedOutAsync(user.Id)) { message = string.Format("Your account has been locked out for {0} minutes due to multiple failed login attempts.", ConfigurationManager.AppSettings["DefaultAccountLockoutTimeSpan"].ToString()); }
Or the non-async extension method version as @raju dasa suggested .
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 24, 2016 7:12 AM
All replies
-
User527778624 posted
Hi,
only problem I am having is that the framework has created so many levels of obfuscation that I cant see how to get the lockout status of an "ApplicationUser"Try this code:
if (UserManager.IsLockedOut(user.Id)) //where user is ApplicationUser and UserManager is ApplicationUserManager.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 24, 2016 6:30 AM -
User1724605321 posted
Hi some_yahoo ,
In ASP.NET Identity 2 , you could use below code to if user is locked-out :
if (await UserManager.IsLockedOutAsync(user.Id)) { message = string.Format("Your account has been locked out for {0} minutes due to multiple failed login attempts.", ConfigurationManager.AppSettings["DefaultAccountLockoutTimeSpan"].ToString()); }
Or the non-async extension method version as @raju dasa suggested .
Best Regards,
Nan Yu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, May 24, 2016 7:12 AM -
User323983933 posted
OK I got it.
Not sure why but I was not able to call UserManager from my view. I just added a field to my User object to contain isLockedOut and all is well.
THANKS for the timely and useful answers!
Wednesday, May 25, 2016 9:04 PM