public async Task <ActionResult> ChangePassword([FromBody] ChangePasswordDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState.ValidationState)); } try { var id = _authRepo.GetCurrentUser(); var user = await _authRepo.GetUserById(id); if (user == null) { return(NotFound(new { Error = "user not found" })); } bool isPasswordValid = await _authRepo.IsPasswordValid(model, user); if (!isPasswordValid) { return(BadRequest(new { Error = "incorrect password" })); } bool success = await _authRepo.ResetPassword(model, user); if (!success) { return(StatusCode(StatusCodes.Status500InternalServerError, "An Error Occured while resetting password")); } } catch (Exception e) { _logger.LogError(e.InnerException?.ToString() ?? e.Message); return(StatusCode(StatusCodes.Status500InternalServerError, "Internal Server Error")); } return(Ok(new { Succeded = true })); }