Skip to content

Commit 1d81777

Browse files
committed
Merge branch 'develop'
2 parents 4cb2ce5 + 8e69401 commit 1d81777

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/services/ResourceService.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,29 @@ async function getResources (currentUser, challengeId, roleId, page, perPage) {
5555
boolQuery.push({ match_phrase: { challengeId } })
5656

5757
// logger.warn('User Check')
58-
if (!currentUser || (!currentUser.isMachine && !helper.hasAdminRole(currentUser))) {
59-
// await checkAccess(currentUser, resources)
60-
// if not admin, and not machine, only return submitters
58+
if (!currentUser) {
59+
// if the user is not logged in, only return resources with submitter role ID
6160
boolQuery.push({ match_phrase: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } })
61+
} else if ((!currentUser.isMachine && !helper.hasAdminRole(currentUser))) {
62+
// await checkAccess(currentUser, resources)
63+
// if not admin, and not machine, only return submitters + all my roles
64+
boolQuery.push({
65+
bool: {
66+
should: [
67+
{ match_phrase: { memberId: currentUser.userId } },
68+
{
69+
bool: {
70+
must: [
71+
{ match_phrase: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } }
72+
],
73+
must_not: [
74+
{ match_phrase: { memberId: currentUser.userId } }
75+
]
76+
}
77+
}
78+
]
79+
}
80+
})
6281
} else if (roleId) {
6382
boolQuery.push({ match_phrase: { roleId } })
6483
}

0 commit comments

Comments
 (0)