Prevent adding users to tournament teams by TO's who don't have friend code set
Some checks are pending
E2E Tests / e2e (push) Waiting to run
Tests and checks on push / run-checks-and-tests (push) Waiting to run
Updates translation progress / update-translation-progress-issue (push) Waiting to run

This commit is contained in:
Kalle
2026-02-17 21:44:10 +02:00
parent 0936e70e73
commit a4b7152f72

View File

@@ -13,6 +13,7 @@ import {
tournamentFromDB,
} from "~/features/tournament-bracket/core/Tournament.server";
import { deleteSub } from "~/features/tournament-subs/queries/deleteSub.server";
import * as UserRepository from "~/features/user-page/UserRepository.server";
import invariant from "~/utils/invariant";
import { logger } from "~/utils/logger";
import {
@@ -64,6 +65,10 @@ export const action: ActionFunction = async ({ request, params }) => {
!tournament.teamMemberOfByUser({ id: data.userId }),
"User already on a team",
);
errorToastIfFalsy(
(await UserRepository.findLeanById(data.userId))?.friendCode,
"User has no friend code set",
);
await TournamentTeamRepository.create({
ownerInGameName: await inGameNameIfNeeded({
@@ -237,6 +242,11 @@ export const action: ActionFunction = async ({ request, params }) => {
"User trying to be added currently has an active ban from sendou.ink",
);
errorToastIfFalsy(
(await UserRepository.findLeanById(data.userId))?.friendCode,
"User has no friend code set",
);
joinTeam({
userId: data.userId,
newTeamId: team.id,