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) { ...@@ -164,7 +164,7 @@ function createRouter(db) {
if (isgetMapInfoValid(req)) { if (isgetMapInfoValid(req)) {
const mapId = req.body.mapId; const mapId = req.body.mapId;
const userId = req.body.userId; 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); console.log('Update Vote: ', sql);
db.query( db.query(
sql, sql,
...@@ -178,13 +178,15 @@ function createRouter(db) { ...@@ -178,13 +178,15 @@ function createRouter(db) {
if (results.length === 1) { if (results.length === 1) {
vote = results[0].vote; vote = results[0].vote;
} }
if (vote) { if (!isNaN(vote)) {
req.body.vote = vote; req.body.vote = vote;
getMapInfo(req, res); getMapInfo(req, res);
return; return;
} }
}
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'unexpected result in getVote'}); 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'});
}
} }
}); });
} else { } else {
......
...@@ -242,10 +242,8 @@ const testClient = net.connect({host: 'localhost', port: 3000}, () => { ...@@ -242,10 +242,8 @@ const testClient = net.connect({host: 'localhost', port: 3000}, () => {
console.log('connected to server!'); console.log('connected to server!');
//testClient.write('Hello World Client!\r\n'); //testClient.write('Hello World Client!\r\n');
testClient.write(JSON.stringify({ testClient.write(JSON.stringify({
"mapId": "keineBekannteMap1", "mapId":"7fsfRSUCQ7YwfBEdRk_GivW6qzj","userId":"aKBNg9fbReqLedLiz1KFfA","name":"Summer 2021 - 01"
"name": "keinBekannterMapName1", //"vote": 80
"userId": "keinBekannterUser1",
"vote": 80
})); }));
//test(testClient); //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