mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-11 05:36:10 -05:00
Prevent adding users to tournament teams by TO's who don't have friend code set
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user