File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -898,7 +898,27 @@ async function _filterChallengesByGroupsAccess(currentUser, challenges) {
898
898
const needToCheckForGroupAccess = ! currentUser
899
899
? true
900
900
: ! currentUser . isMachine && ! hasAdminRole ( currentUser ) ;
901
- if ( ! needToCheckForGroupAccess ) return challenges ;
901
+ if ( ! needToCheckForGroupAccess )
902
+ {
903
+ for ( const challenge of challenges ) {
904
+ if ( challenge && challenge . groups && challenge . groups . length > 0 ) {
905
+ const promises = [ ] ;
906
+ _ . each ( challenge . groups , ( g ) => {
907
+ promises . push (
908
+ ( async ( ) => {
909
+ const group = await getGroupById ( g ) ;
910
+ if ( ! group || ! group . status === 'active' ) {
911
+ throw new errors . BadRequestError ( "The groups provided are invalid " + g ) ;
912
+ }
913
+ } ) ( )
914
+ ) ;
915
+ } ) ;
916
+ await Promise . all ( promises ) ;
917
+ res . push ( challenge ) ;
918
+ }
919
+ }
920
+ return res ;
921
+ }
902
922
903
923
let userGroups ;
904
924
You can’t perform that action at this time.
0 commit comments