public async Task <IActionResult> ChangePassword(AjaxUserChangrPassword model, CancellationToken cancellationToken) { CustomUser user = await _userManager.FindByIdAsync(model.Id); AjaxResult result = new AjaxResult("Error"); if (user != null) { IdentityResult changeResult = await _userManager.ChangePasswordAsync(user, model.OldPassWord, model.NewPassWords); if (changeResult.Succeeded) { result.Status = "Success"; result.MessageWhenSuccessed = "پسوورد با موفقیت تغییر کرد"; result.RedirectUrl = "/User/Home/Index"; return(new JsonResult(result)); } else { ModelState.AddModelStateError(changeResult.Errors.Select(c => c.Description)); } result.AddErrors(ModelState); return(new JsonResult(result)); } ModelState.AddModelError("", "کاربر یافت نشد"); result.AddErrors(ModelState); return(new JsonResult(result)); }
public IActionResult ChangePassword() { AjaxUserChangrPassword model = new AjaxUserChangrPassword { Id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value }; return(PartialView("ChangePasswordPartialView", model)); }