Commit c857d223 authored by Matthieu - Greep's avatar Matthieu - Greep

Fix player check

parent bdb7089f
Pipeline #460 passed with stage
in 51 seconds
...@@ -20,10 +20,7 @@ module.exports = function(app, sql, tokenCheck, errorHandler) { ...@@ -20,10 +20,7 @@ module.exports = function(app, sql, tokenCheck, errorHandler) {
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)
tmioPlayer.player(player).then((playerData)=>{ tmioPlayer.player(player).then(()=>{
if (playerData.error) return errorHandler(res, 400, playerData.error);
});
sql.query('SELECT * FROM votes WHERE map = ? AND player = ?', [mapId,player], (err, sqlRes)=>{ sql.query('SELECT * FROM votes WHERE map = ? AND player = ?', [mapId,player], (err, sqlRes)=>{
if (err) { if (err) {
console.log(err); console.log(err);
...@@ -63,6 +60,8 @@ module.exports = function(app, sql, tokenCheck, errorHandler) { ...@@ -63,6 +60,8 @@ module.exports = function(app, sql, tokenCheck, errorHandler) {
} }
} }
}); });
})
.catch((err)=>errorHandler(res, 400, err)); // player not found
//}); //});
}); });
}; };
\ No newline at end of file
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