Commit 534553a2 authored by Dennis Willers's avatar Dennis Willers 🏀

Prevent Tabu 4 same time pressing tabu

parent 748d2225
Pipeline #342 passed with stages
in 3 minutes and 10 seconds
...@@ -305,8 +305,34 @@ function createRouter(db) { ...@@ -305,8 +305,34 @@ function createRouter(db) {
} }
}; };
const isPoint4Card = function isPoint4Card(req, res, next) {
const spielname = req.body.spielname;
const cardID = req.body.cardID;
if (spielname.match(/^[0-9a-z]+$/) != null && !isNaN(cardID)) {
const sql = 'SELECT ActiveCard FROM Gamestatus WHERE SessionID = (SELECT SessionID FROM Session WHERE SessionName = \"'+spielname+'\");';
console.log('isPoint4Card: ', sql);
db.query(sql,
(error, results) => {
if (error) {
console.log(error);
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false'});
} else {
resultCardID = results[0].ActiveCard;
if (JSON.parse(resultCardID) === JSON.parse(cardID)) {
next();
} else {
res.header('Access-Control-Allow-Origin', "*").status(200).json({status: 'false'});
}
}
}
);
} else {
res.header('Access-Control-Allow-Origin', "*").status(500).json({status: 'false body informal'});
}
};
const addPoint = function addPoint(req, res) { const addPoint = function addPoint(req, res) {
console.log(req.body);
const spielname = req.body.spielname; const spielname = req.body.spielname;
const team = req.body.team; const team = req.body.team;
if (spielname.match(/^[0-9a-z]+$/) != null && team.match(/^[0-9a-z]+$/) != null) { if (spielname.match(/^[0-9a-z]+$/) != null && team.match(/^[0-9a-z]+$/) != null) {
...@@ -357,7 +383,6 @@ function createRouter(db) { ...@@ -357,7 +383,6 @@ function createRouter(db) {
}; };
const removePoint = function removePoint(req, res) { const removePoint = function removePoint(req, res) {
console.log(req.body);
const spielname = req.body.spielname; const spielname = req.body.spielname;
const team = req.body.team; const team = req.body.team;
if (spielname.match(/^[0-9a-z]+$/) != null && team.match(/^[0-9a-z]+$/) != null) { if (spielname.match(/^[0-9a-z]+$/) != null && team.match(/^[0-9a-z]+$/) != null) {
...@@ -465,10 +490,10 @@ function createRouter(db) { ...@@ -465,10 +490,10 @@ function createRouter(db) {
router.post('/newGame', [isSession, isActiveExplainer, newGame]); router.post('/newGame', [isSession, isActiveExplainer, newGame]);
//Add Point //Add Point
router.post('/addPoint', [addPoint]); router.post('/addPoint', [isPoint4Card, addPoint]);
//Remove Point //Remove Point
router.post('/removePoint', [removePoint]); router.post('/removePoint', [isPoint4Card, removePoint]);
//Get ActiveCard //Get ActiveCard
router.post('/getActiveCard', [isSession, getActiveCard]); router.post('/getActiveCard', [isSession, getActiveCard]);
......
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