X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=server%2Froutes%2Fproblems.js;fp=server%2Froutes%2Fproblems.js;h=a0886db5b3706d1900a08d4cffe619517e9755c5;hb=604b951e4dc4647da9b251c5fff4ecb4c7b1b298;hp=c45a1baccd43f0aa5925d4bfb8c65393d76d382d;hpb=89021f181ac0689bbc785ce0ebd9a910e66352b0;p=vchess.git diff --git a/server/routes/problems.js b/server/routes/problems.js index c45a1bac..a0886db5 100644 --- a/server/routes/problems.js +++ b/server/routes/problems.js @@ -43,17 +43,13 @@ router.post("/problems", access.logged, access.ajax, (req,res) => { }); router.put("/problems", access.logged, access.ajax, (req,res) => { - const pid = req.body.pid; - let error = ""; - if (!pid.toString().match(/^[0-9]+$/)) - error = "Wrong problem ID"; - let obj = req.body.newProb; - error = ProblemModel.checkProblem(obj); - obj.instruction = sanitizeHtml(obj.instruction); - obj.solution = sanitizeHtml(obj.solution); + let obj = req.body.prob; + const error = ProblemModel.checkProblem(obj); if (!!error) return res.json({errmsg: error}); - ProblemModel.update(pid, obj, (err) => { + obj.instruction = sanitizeHtml(obj.instruction); + obj.solution = sanitizeHtml(obj.solution); + ProblemModel.update(obj, (err) => { res.json(err || {}); }); });