Skip to content

Commit 543faf5

Browse files
committed
add safety for find query in associated can dos
1 parent d4b7e1b commit 543faf5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

server/services/contributions/hooks/getAssociatedCanDos.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ module.exports = function (options = {}) { // eslint-disable-line no-unused-vars
99
return resolve(hook);
1010
}
1111

12+
// Stop, if it was a find method and $limit was not set
13+
if (hook.method === 'find' && (!hook.params.query || hook.params.query.$limit !== 1)) {
14+
return resolve(hook);
15+
}
16+
1217
// Stop, if we have an empty array or more then one item
1318
let isArray = hook.result.data && Array.isArray(hook.result.data)
1419
if (isArray && (!hook.result.data.length || hook.result.data.length > 1)) {

0 commit comments

Comments
 (0)