ASP.NET Identity reset password

前端 未结 10 1074
无人及你
无人及你 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:35

    Create method in UserManager

    public Task ChangePassword(int userId, string newPassword)
    {
         var user = Users.FirstOrDefault(u => u.Id == userId);
         if (user == null)
              return new Task(() => IdentityResult.Failed());
    
         var store = Store as IUserPasswordStore;
         return base.UpdatePassword(store, user, newPassword);
    }
    

提交回复
热议问题