File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,18 @@ export const setupQuizRoutes = function(app: Express, prisma: PrismaClient): voi
361
361
const coalitionId = parseInt ( req . body . coalition_id ) ;
362
362
console . log ( `User ${ user . login } requested to join coalition ${ coalitionId } ` ) ;
363
363
364
+
365
+ // Check if coalitionId is actually in our database
366
+ const coalition = await prisma . intraCoalition . findFirst ( {
367
+ where : {
368
+ id : coalitionId
369
+ }
370
+ } ) ;
371
+ if ( ! coalition ) {
372
+ console . warn ( `User ${ user . login } tried to join a non-existing coalition ${ coalitionId } ` ) ;
373
+ return res . status ( 400 ) . send ( { error : 'Whatever you\'re trying to do, stop' } ) ;
374
+ }
375
+
364
376
// Check if all questions have been answered
365
377
if ( ! await areAllQuestionsAnswered ( prisma , userSession ) ) {
366
378
console . log ( `User ${ user . login } tried to join a coalition without answering all questions` ) ;
You can’t perform that action at this time.
0 commit comments