Skip to content

Commit f5acfa0

Browse files
committed
Revert "refactor: streamline id handling and security checks in runFindTriggers"
This reverts commit 0d68f26.
1 parent 0d68f26 commit f5acfa0

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/rest.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async function runFindTriggers(
3434
options = {}
3535
) {
3636
const { isGet } = options;
37+
3738
// Run beforeFind trigger - may modify query or return objects directly
3839
const result = await triggers.maybeRunQueryTrigger(
3940
triggers.Types.beforeFind,
@@ -58,18 +59,11 @@ async function runFindTriggers(
5859

5960
// Security check: Re-filter objects if not master to ensure ACL/CLP compliance
6061
if (!auth?.isMaster && !auth?.isMaintenance) {
61-
const inputArray = Array.isArray(objectsFromBeforeFind)
62-
? objectsFromBeforeFind
63-
: [objectsFromBeforeFind];
64-
65-
const ids = inputArray
62+
const ids = (Array.isArray(objectsFromBeforeFind) ? objectsFromBeforeFind : [objectsFromBeforeFind])
6663
.map(o => (o && (o.id || o.objectId)) || null)
6764
.filter(Boolean);
6865

69-
// If no valid ids are present, do not return unsanitized data
70-
if (ids.length === 0) {
71-
objectsForAfterFind = [];
72-
} else {
66+
if (ids.length > 0) {
7367
const refilterWhere = isGet ? { objectId: ids[0] } : { objectId: { $in: ids } };
7468

7569
// Re-query with proper security: no triggers to avoid infinite loops

0 commit comments

Comments
 (0)