请建议最佳做法是在Asp.Identity中通过UserManager更新数据库中的新密码
目前我正在使用以下方法更新密码。这还不够,或者我想用不同的方法?
ApplicationDbContext context = new ApplicationDbContext();
UserStore<ApplicationUser> store = new UserStore<ApplicationUser>(context);
UserManager<ApplicationUser> UserManager = new UserManager<ApplicationUser>(store);
String userId = User.Identity.GetUserId();//"<YourLogicAssignsRequestedUserId>";
String newPassword = "test@123"; //"<PasswordAsTypedByUser>";
String hashedNewPassword = UserManager.PasswordHasher.HashPassword(newPassword);
ApplicationUser cUser = await store.FindByIdAsync(userId);
**await store.SetPasswordHashAsync(cUser, hashedNewPassword);
await store.UpdateAsync(cUser);**