Skip to content

Commit c93f446

Browse files
Update resources API to return all roles when searching for your own member ID
1 parent 8637689 commit c93f446

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/services/ResourceService.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,24 @@ async function getResources (currentUser, challengeId, roleId, page, perPage) {
5757
// logger.warn('User Check')
5858
if (!currentUser || (!currentUser.isMachine && !helper.hasAdminRole(currentUser))) {
5959
// await checkAccess(currentUser, resources)
60-
// if not admin, and not machine, only return submitters
61-
boolQuery.push({ match_phrase: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } })
60+
// if not admin, and not machine, only return submitters + all my roles
61+
boolQuery.push({
62+
bool: {
63+
should: [
64+
{ match_phrase: { memberId: currentUser.userId } },
65+
{
66+
bool: {
67+
must: [
68+
{ match_phrase: { roleId: config.SUBMITTER_RESOURCE_ROLE_ID } }
69+
],
70+
must_not: [
71+
{ match_phrase: { memberId: currentUser.userId } }
72+
]
73+
}
74+
}
75+
]
76+
}
77+
})
6278
} else if (roleId) {
6379
boolQuery.push({ match_phrase: { roleId } })
6480
}

0 commit comments

Comments
 (0)