Skip to content

Commit

Permalink
Contacts|Contactgroups endpoints: Only allow filter on GET method
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jul 3, 2024
1 parent 898009b commit 8453e00
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 6 additions & 1 deletion application/controllers/ApiV1ContactgroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ public function indexAction(): void
$this->httpBadRequest('The given identifier is not a valid UUID');
}

$filterStr = rawurldecode(Url::fromRequest()->getQueryString());
if ($method !== 'GET' && $filterStr) {
$this->httpBadRequest('Filter is only allowed for GET requests');
}

$filter = FilterProcessor::assembleFilter(
QueryString::fromString(rawurldecode(Url::fromRequest()->getQueryString()))
QueryString::fromString($filterStr)
->on(
QueryString::ON_CONDITION,
function (Filter\Condition $condition) {
Expand Down
11 changes: 6 additions & 5 deletions application/controllers/ApiV1ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ public function indexAction(): void
$this->httpBadRequest('The given identifier is not a valid UUID');
}

$filterStr = rawurldecode(Url::fromRequest()->getQueryString());
if ($method !== 'GET' && $filterStr) {
$this->httpBadRequest('Filter is only allowed for GET requests');
}

$filter = FilterProcessor::assembleFilter(
QueryString::fromString(rawurldecode(Url::fromRequest()->getQueryString()))
QueryString::fromString($filterStr)
->on(
QueryString::ON_CONDITION,
function (Filter\Condition $condition) {
Expand Down Expand Up @@ -164,10 +169,6 @@ function (Filter\Condition $condition) {

exit;
case 'POST':
if ($filter !== null) {
$this->httpBadRequest('Cannot filter on POST');
}

$data = $this->getValidatedData();

$db->beginTransaction();
Expand Down

0 comments on commit 8453e00

Please sign in to comment.