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

后端 未结 7 1536
情深已故
情深已故 2021-01-30 06:36

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 bu

7条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-30 07:24

    I added this to my UserManager class :

        public virtual async Task UpdatePassword(ApplicationUser user, string newPassword)
        {
            var passwordStore = Store as IUserPasswordStore;
    
            if (passwordStore == null)
                throw new Exception("UserManager store does not implement IUserPasswordStore");
    
            var result = await base.UpdatePassword(passwordStore, user, newPassword);
    
            if (result.Succeeded)
                result = await base.UpdateAsync(user);
    
            return result;
        }
    

提交回复
热议问题