From fd1d412d46b04f5a458e9b8be982c9c5e7c9873e Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 15 Feb 2024 00:13:49 +0200 Subject: [PATCH] Add backend check for joining two tournament teams Closes #1666 --- app/features/tournament/routes/to.$id.register.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/features/tournament/routes/to.$id.register.tsx b/app/features/tournament/routes/to.$id.register.tsx index 2be5a0a96..67814f916 100644 --- a/app/features/tournament/routes/to.$id.register.tsx +++ b/app/features/tournament/routes/to.$id.register.tsx @@ -99,11 +99,10 @@ export const action: ActionFunction = async ({ request, params }) => { const tournamentId = tournamentIdFromParams(params); const tournament = await tournamentFromDB({ tournamentId, user }); - const hasStarted = hasTournamentStarted(tournamentId); const event = notFoundIfFalsy(findByIdentifier(tournamentId)); validate( - !hasStarted, + tournament.ctx.inProgressBrackets.length === 0, "Tournament has started, cannot make edits to registration", ); @@ -122,6 +121,10 @@ export const action: ActionFunction = async ({ request, params }) => { }); } else { validate(!HACKY_isInviteOnlyEvent(event), "Event is invite only"); + validate( + !tournament.teamMemberOfByUser(user), + "You are already in a team that you aren't captain of", + ); createTeam({ name: data.teamName,