ASP.NET Identity reset password

前端 未结 10 1124
无人及你
无人及你 2020-12-02 05:09

How can I get the password of a user in the new ASP.NET Identity system? Or how can I reset without knowing the current one (user forgot password)?

10条回答
  •  醉酒成梦
    2020-12-02 05:38

    Or how can I reset without knowing the current one (user forgot password)?

    If you want to change a password using the UserManager but you do not want to supply the user's current password, you can generate a password reset token and then use it immediately instead.

    string resetToken = await UserManager.GeneratePasswordResetTokenAsync(model.Id);
    IdentityResult passwordChangeResult = await UserManager.ResetPasswordAsync(model.Id, resetToken, model.NewPassword);
    

提交回复
热议问题