Skip to content

Commit c55ca76

Browse files
Remove logging and add a fix on group access
1 parent 12f5df7 commit c55ca76

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/services/ChallengeService.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ const esClient = helper.getESClient()
2525
async function filterChallengesByGroupsAccess (currentUser, challenges) {
2626
const res = []
2727
let userGroups
28+
const needToCheckForGroupAccess = currentUser && !currentUser.isMachine && !helper.hasAdminRole(currentUser)
2829
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) {
3031
res.push(challenge)
3132
} else if (currentUser) {
3233
// get user groups if not yet
@@ -177,9 +178,7 @@ async function searchChallenges (currentUser, criteria) {
177178
// Extract data from hits
178179
const total = docs.hits.total
179180
let result = _.map(docs.hits.hits, item => item._source)
180-
console.log(`hits before filtering by groups access: ${result.length}`)
181181
result = await filterChallengesByGroupsAccess(currentUser, result)
182-
console.log(`hits after filtering by groups access: ${result.length}`)
183182

184183
// Hide privateDescription for non-register challenges
185184
if (currentUser) {

0 commit comments

Comments
 (0)