X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Fmodels%2FGame.js;h=39459176acfbe534c002dbca46e69a1de184c262;hb=188b4a8f2e3edfa86c4e9169ddac9a14ebc12689;hp=92c013016034416daf8f27772acac4ae5553ecb0;hpb=3b64b66722edfed26978c2894e5357d066f33943;p=vchess.git diff --git a/server/models/Game.js b/server/models/Game.js index 92c01301..39459176 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -197,17 +197,17 @@ const GameModel = return ( ( !obj.move || ( - obj.move.played.toString().match(/^[0-9]+$/) && - obj.move.idx.toString().match(/^[0-9]+$/) + !!(obj.move.played.toString().match(/^[0-9]+$/)) && + !!(obj.move.idx.toString().match(/^[0-9]+$/)) ) ) && ( - !obj.drawOffer || obj.drawOffer.match(/^[wbtn]$/) + !obj.drawOffer || !!(obj.drawOffer.match(/^[wbtn]$/)) ) && ( - !obj.fen || obj.fen.match(/^[a-zA-Z0-9, /-]*$/) + !obj.fen || !!(obj.fen.match(/^[a-zA-Z0-9, /-]*$/)) ) && ( - !obj.score || obj.score.match(/^[012?*\/-]+$/) + !obj.score || !!(obj.score.match(/^[012?*\/-]+$/)) ) && ( - !obj.scoreMsg || obj.scoreMsg.match(/^[a-zA-Z ]+$/) + !obj.scoreMsg || !!(obj.scoreMsg.match(/^[a-zA-Z ]+$/)) ) && ( !obj.chat || UserModel.checkNameEmail({name: obj.chat.name}) ) @@ -243,7 +243,7 @@ const GameModel = db.run(query); } // NOTE: move, chat and delchat are mutually exclusive - if (obj.move) + if (!!obj.move) { // Security: only update moves if index is right query = @@ -252,10 +252,6 @@ const GameModel = "WHERE gid = " + id; db.get(query, (err,ret) => { const m = obj.move; - -return cb({errmsg: ret.maxIdx + " " + m.idx + " " + (!ret.maxIdx || ret.maxIdx + 1 == m.idx) + " " + query}); - - if (!ret.maxIdx || ret.maxIdx + 1 == m.idx) { query = "INSERT INTO Moves (gid, squares, played, idx) VALUES " +