File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,9 @@ const esClient = helper.getESClient()
25
25
async function filterChallengesByGroupsAccess ( currentUser , challenges ) {
26
26
const res = [ ]
27
27
let userGroups
28
+ const needToCheckForGroupAccess = currentUser && ! currentUser . isMachine && ! helper . hasAdminRole ( currentUser )
28
29
for ( const challenge of challenges ) {
29
- if ( ! challenge . groups || challenge . groups . length === 0 || ( currentUser && ( currentUser . isMachine || helper . hasAdminRole ( currentUser ) ) ) ) {
30
+ if ( ! challenge . groups || _ . get ( challenge , ' groups.length' , 0 ) === 0 || ! needToCheckForGroupAccess ) {
30
31
res . push ( challenge )
31
32
} else if ( currentUser ) {
32
33
// get user groups if not yet
@@ -177,9 +178,7 @@ async function searchChallenges (currentUser, criteria) {
177
178
// Extract data from hits
178
179
const total = docs . hits . total
179
180
let result = _ . map ( docs . hits . hits , item => item . _source )
180
- console . log ( `hits before filtering by groups access: ${ result . length } ` )
181
181
result = await filterChallengesByGroupsAccess ( currentUser , result )
182
- console . log ( `hits after filtering by groups access: ${ result . length } ` )
183
182
184
183
// Hide privateDescription for non-register challenges
185
184
if ( currentUser ) {
You can’t perform that action at this time.
0 commit comments