I have code in my controller to disable an account. The code was working fine. Now, all of a sudden it isn't.
public async Task<ActionResult> DisableClient(string userId, int disableAccount)
{
bool disable = (disableAccount != 0);
ApplicationUser user = UserManager.FindById(userId);
if (user != null && user.Disabled != disable)
{
user.UserName = disable ? DisabledUserName : user.Email; // Not sure if this is needed
user.Disabled = disable;
// Generating a new security stamp invalidates the user's
// session, effectively locking them out
if (user.Disabled)
await UserManager.UpdateSecurityStampAsync(userId);
await UserManager.UpdateAsync(user);
}
return RedirectToAction("Details", "Client", new { userId = userId });
}
ApplicationUser.Disabled
was mapping to AspNetUsers.Disabled
. But now, I can see the code above setting this property to true
, but the value in the database remains false
.
I don't understand how this could've changed. Can anyone help explain this?