Commit 69ff96f8 authored by Dennis Willers's avatar Dennis Willers
Browse files

Merge branch 'fix-setVote' into 'master'

Fix missing vote

See merge request Dennis.Willers/voting!3
parents 2fb7e8e1 46572e12
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -10,13 +10,11 @@ const path = require('path'),
module.exports = function(app, sql, errorHandler) {
module.exports = function(app, sql, errorHandler) {
    app.post('/'+scriptName, function(req, res) {
    app.post('/'+scriptName, function(req, res) {
        const mapId = req.query.map || req.body.map,
        const mapId = req.query.map || req.body.map,
            player = req.query.player || req.body.player;
            player = req.query.player || req.body.player,
        let vote = req.query.vote || req.body.vote;
            vote = Number(req.query.vote || req.body.vote);
        if (!mapId) return errorHandler(res, 400, 'Missing map id');
        if (!mapId) return errorHandler(res, 400, 'Missing map id');
        if (!player) return errorHandler(res, 400, 'Missing player login');
        if (!player) return errorHandler(res, 400, 'Missing player login');
        if (!vote) return errorHandler(res, 400, 'Missing vote');
        if (isNaN(vote)) return errorHandler(res, 400, 'Missing vote');
        vote = Number(vote);
        if (isNaN(vote)) return errorHandler(res, 400, 'Invalid vote');
        if (vote < 0 || vote > 100) return errorHandler(res, 400, 'Vote must be between 0 and 100');
        if (vote < 0 || vote > 100) return errorHandler(res, 400, 'Vote must be between 0 and 100');


        // check if player exists (tmio API check)
        // check if player exists (tmio API check)