X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=server%2Froutes%2Fgames.js;h=21aee475b79a4980f0d8dad06a637de96efba466;hp=57656f41893371923baec642eef92054f378000b;hb=c292ebb2a014646005b01e27253c162f1d639387;hpb=afde76668963c4d0d96002fcae2ebabb9acf81e4 diff --git a/server/routes/games.js b/server/routes/games.js index 57656f41..21aee475 100644 --- a/server/routes/games.js +++ b/server/routes/games.js @@ -8,14 +8,15 @@ const params = require("../config/parameters"); // From main hall, start game between players 0 and 1 router.post("/games", access.logged, access.ajax, (req,res) => { const gameInfo = req.body.gameInfo; + // Challenge ID is provided if game start from Hall: const cid = req.body.cid; if ( Array.isArray(gameInfo.players) && gameInfo.players.some(p => p.id == req.userId) && - cid.toString().match(/^[0-9]+$/) && + (!cid || cid.toString().match(/^[0-9]+$/)) && GameModel.checkGameInfo(gameInfo) ) { - ChallengeModel.remove(cid); + if (!!cid) ChallengeModel.remove(cid); GameModel.create( gameInfo.vid, gameInfo.fen, gameInfo.cadence, gameInfo.players, (err,ret) => {