public async Task <IActionResult> ResetPassword([FromBody] ResetUserPasswordDTO resetUserPasswordDTO) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } var user = await _userManager.FindByNameAsync(resetUserPasswordDTO.Username); var result = await _userManager.ResetPasswordAsync(user, resetUserPasswordDTO.Token, resetUserPasswordDTO.NewPassword); if (result.Succeeded) { if (await _emailSenderService.SendResetedPasswordEmail(user.Email, user.UserName)) { return(CustomResponse()); } AddError("Email cannot be sent."); return(CustomResponse()); } foreach (var error in result.Errors) { AddError(error.Description); } return(CustomResponse()); }