I am trying to increase AccessFailedCount with this code, but it does not work (in the AspNetUsers table the number of AccessFailed does not increase). => In this code, My first reaction was that when the user was unable to log in to increase the AccessFailed account, but did not work with this code. Please give me a suggestion for the upgrade code and any things.
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var user = manager.FindByName(txtUserName.Text);
if (user != null)
{
var validCredentials = manager.Find(txtUserName.Text, txtPassword.Text);
if (manager.IsLockedOut(user.Id))
{
error message;
}
else if (manager.GetLockoutEnabled(user.Id) && validCredentials == null && manager.SupportsUserLockout)
{
manager.AccessFailed(user.Id);
if (manager.IsLockedOut(user.Id))
{
error message;
}
else
{
int accessFailedCount = manager.GetAccessFailedCount(user.Id);
}
}
else
{
IdentityHelper.SignIn(manager, user, RememberMe.Checked);
manager.ResetAccessFailedCount(user.Id);
Response.Redirect("/Home.aspx", false);
}
}
source
share