From 024f509b0e268b64c342312dd91b1eca500fe382 Mon Sep 17 00:00:00 2001 From: RHM Date: Sat, 13 Sep 2025 21:58:10 +0200 Subject: [PATCH] abc --- backend/src/api.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/src/api.js b/backend/src/api.js index 215ab04..e541135 100644 --- a/backend/src/api.js +++ b/backend/src/api.js @@ -213,8 +213,9 @@ router.post("/games", asyncHandler(async (req, res) => { try { await conn.beginTransaction(); + const [gameResult] = await conn.query( - "INSERT INTO current_games (is_open, is_local) VALUES (?, ?, ?)", + "INSERT INTO current_games (is_open, is_local) VALUES (?, ?)", [true, is_local] ); @@ -279,6 +280,13 @@ router.post("/games/:id/players", asyncHandler(async (req, res) => { try { await conn.beginTransaction(); + + const [alreadyJoined] = await conn.query( + "SELECT 1 FROM game_players WHERE game = ? AND user = ?", + [gameId, user] + ); + if (alreadyJoined.length) throw new ApiError(400, "User already joined this game"); + const [gameRows] = await conn.query( "SELECT * FROM current_games WHERE id = ? AND is_open = TRUE AND is_local = FALSE", [gameId]