Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
narcoticfresh committed Mar 22, 2024
1 parent 859d8bc commit d4e2316
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/Graviton/RestBundle/Listener/RestrictionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public function onPreAggregate(PreAggregateEvent $event)
$matchConditions[] = [
'$or' => [
[$fieldName => null],
[$fieldName => ['$lte' => (int) $fieldValue]], // always int
[$fieldName => ['$lte' => (int) $fieldValue]], // always int in lte
]
];
} else {
Expand All @@ -235,7 +235,12 @@ public function onPreAggregate(PreAggregateEvent $event)
}

$newPipeline = [];
if (!empty($matchConditions)) {
if (!empty($matchConditions) && count($matchConditions) == 1) {
$newPipeline[] = [
'$match' => $matchConditions
];
}
if (!empty($matchConditions) && count($matchConditions) > 1) {
$newPipeline[] = [
'$match' => [
'$and' => $matchConditions
Expand All @@ -257,7 +262,7 @@ public function onPreAggregate(PreAggregateEvent $event)
[
'mode' => $this->securityUtils->getDataRestrictionMode(),
'values' => $dataRestrictions,
'pipeline' => $newPipeline
'pipeline' => \json_encode($newPipeline, JSON_UNESCAPED_SLASHES)
]
);

Expand Down
2 changes: 1 addition & 1 deletion src/Graviton/SecurityBundle/Service/SecurityUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function getRequestDataRestrictions()
if (!is_null($headerValue) && $fieldSpec['type'] == 'int') {
$headerValue = (int) $headerValue;
}
$restrictions[$fieldSpec['name']] = (string) $headerValue;
$restrictions[$fieldSpec['name']] = $headerValue;
}
return $restrictions;
}
Expand Down

0 comments on commit d4e2316

Please sign in to comment.