请建议通过 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);**