@@ -339,33 +339,11 @@ async function searchChallenges (currentUser, criteria) {
339
339
}
340
340
}
341
341
342
- /*
343
- Long and drawn out filter to hide tasks from challenge list unless:
344
- 1. You're not specifically searching for them (What if you include a task type in your filter, do you see assigned ones?)
345
- 2. You're not searching for a legacyId
346
- 3. You're not getting a member's challenges
347
- 4. You're not an M2M or Admin
348
- 5. The member ID is not the current requesting user JWT
349
- */
350
342
// FIXME: Tech Debt
351
- let excludeTasks = false
352
- // If you're not looking for a particular type or a specific challenge, exclude tasks
353
- if ( _ . isUndefined ( criteria . type ) && includedTypeIds . length === 0 && _ . isUndefined ( criteria . legacyId ) ) {
354
- excludeTasks = true
355
- }
356
- if ( ! _ . isUndefined ( criteria . memberId ) ) {
357
- // If a memberId is provided by a non-admin/M2M, exclude tasks
358
- if ( ! helper . hasAdminRole ( currentUser ) && ! _ . get ( currentUser , 'isMachine' , false ) ) {
359
- excludeTasks = true
360
- }
361
- // If the authenticated member is not looking for his own challenges, exclude tasks
362
- if ( criteria . memberId !== _ . get ( currentUser , 'userId' ) ) {
363
- excludeTasks = true
364
- }
365
- }
366
- // Exclude tasks for unauthenticated users
367
- if ( _ . isUndefined ( currentUser ) ) {
368
- excludeTasks = true
343
+ let excludeTasks = true
344
+ // if you're an admin or m2m, security rules wont be applied
345
+ if ( currentUser && ( helper . hasAdminRole ( currentUser ) || _ . get ( currentUser , 'isMachine' , false ) ) ) {
346
+ excludeTasks = false
369
347
}
370
348
371
349
/**
@@ -384,8 +362,8 @@ async function searchChallenges (currentUser, criteria) {
384
362
if ( criteria . taskIsAssigned ) {
385
363
boolQuery . push ( { match_phrase : { 'task.isAssigned' : criteria . taskIsAssigned } } )
386
364
}
387
- if ( criteria . taskMemberId ) {
388
- boolQuery . push ( { match_phrase : { 'task.memberId' : criteria . taskMemberId } } )
365
+ if ( criteria . taskMemberId || criteria . memberId ) {
366
+ boolQuery . push ( { match_phrase : { 'task.memberId' : criteria . taskMemberId || criteria . memberId } } )
389
367
}
390
368
} else if ( excludeTasks ) {
391
369
mustQuery . push ( {
0 commit comments