public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await AplicationUserService.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { var user = await AplicationUserService.FindByIdAsync(User.Identity.GetUserId()); if (user != null) { await AplicationSignInService.SignInAsync(user, isPersistent : false, rememberBrowser : false); } return(RedirectToAction("Index", new { Message = ManageMessageId.ChangePasswordSuccess })); } AddErrors(result); return(View(model)); }
public async Task <ActionResult> ChangePassword(ChangePasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await userService.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (result.Succeeded) { this.NotifySuccess("Successfully changed."); return(RedirectToAction("Index", new { Message = "" })); } else { this.NotifyError("Password can not change!"); } return(View(model)); }