public async Task <IHttpActionResult> ChangePassword(AccountChangePasswordApplicationUserViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await _accountService.ChangeUserPasswordAsync(User.Identity.GetUserId(), model.OldPassword, model.NewPassword); if (!result.Succeeded) { return(GetErrorResult(result)); } _accountService.Logout(CookieAuthenticationDefaults.AuthenticationType); return(Ok()); }
public async Task <ActionResult> ChangePassword(AccountChangePasswordApplicationUserViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await _accountService.FindUserByUserNameAsync(HttpContext.User.Identity.Name); var result = await _accountService.ChangeUserPasswordAsync(user.Id, model.OldPassword, model.NewPassword); if (result.Succeeded) { return(RedirectToAction("Login", "Account")); } AddErrors(result); return(View(model)); }