Commit 238b8299 authored by Dennis Willers's avatar Dennis Willers 🏀

Fix Bug with check if vote is a number

parent 1a692230
Pipeline #429 passed with stages
in 2 minutes and 44 seconds
......@@ -164,7 +164,7 @@ function createRouter(db) {
if (isgetMapInfoValid(req)) {
const mapId = req.body.mapId;
const userId = req.body.userId;
const sql = 'SELECT vote FROM Vote v2 WHERE mapId LIKE \"'+ mapId + '\" AND userId LIKE \"' + userId + '\";';
const sql = 'SELECT vote FROM Vote WHERE mapId LIKE \"'+ mapId + '\" AND userId LIKE \"' + userId + '\";';
console.log('Update Vote: ', sql);
db.query(
sql,
......@@ -178,13 +178,15 @@ function createRouter(db) {
if (results.length === 1) {
vote = results[0].vote;
}
if (vote) {
if (!isNaN(vote)) {
req.body.vote = vote;
getMapInfo(req, res);
return;
}
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getVote'});
} else {
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'too many results in getVote'});
}
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getVote'});
}
});
} else {
......
......@@ -242,10 +242,8 @@ const testClient = net.connect({host: 'localhost', port: 3000}, () => {
console.log('connected to server!');
//testClient.write('Hello World Client!\r\n');
testClient.write(JSON.stringify({
"mapId": "keineBekannteMap1",
"name": "keinBekannterMapName1",
"userId": "keinBekannterUser1",
"vote": 80
"mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"
//"vote": 80
}));
//test(testClient);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment