How to reset password with UserManager of ASP.NET MVC 5

DmitryBoyko picture DmitryBoyko · Mar 19, 2014 · Viewed 71.2k times · Source

I am wondering if there is a way to reset password with UserManager of ASP.NET MVC 5

I tried this with user that already has a password but no success. Any clue?

IdentityResult result = UserManager.AddPassword(forgotPasswordEvent.UserId.ToString(), model.ConfirmPassword);
if (result.Succeeded)
{
       //
}
else
{
        AddErrors(result);
}

Answer

DmitryBoyko picture DmitryBoyko · Mar 20, 2014

It is here ASP.NET Identity reset password

UserManager<IdentityUser> userManager = 
    new UserManager<IdentityUser>(new UserStore<IdentityUser>());

userManager.RemovePassword(userId);

userManager.AddPassword(userId, newPassword);