From bec764dcee9b17f5562203885d69e0bb4004f947 Mon Sep 17 00:00:00 2001 From: Nathaniel Tampus Date: Wed, 5 Apr 2023 22:17:25 +0800 Subject: [PATCH] improve id checks for getting finished games --- server/src/controllers/games.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/controllers/games.controller.ts b/server/src/controllers/games.controller.ts index 22438c2..1d0244e 100644 --- a/server/src/controllers/games.controller.ts +++ b/server/src/controllers/games.controller.ts @@ -11,7 +11,7 @@ export const getGames = async (req: Request, res: Response) => { return; } - if (req.query.id) { + if (req.query.id && Number.isFinite(req.query.id)) { // get finished game by id const game = await GameModel.findById(parseInt(req.query.id as string)); if (!game) { @@ -19,7 +19,7 @@ export const getGames = async (req: Request, res: Response) => { } else { res.status(200).json(game); } - } else if (req.query.userid) { + } else if (req.query.userid && Number.isFinite(req.query.userid)) { // get finished games by user id const games = await GameModel.findByUserId(parseInt(req.query.userid as string)); if (!games) {