mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Fixing to body from decoded.
This commit is contained in:
+11
-11
@@ -779,18 +779,18 @@ adminRoutes.get('/ports', function (req, res) {
|
||||
});
|
||||
|
||||
adminRoutes.post('/ports', function (req, res) {
|
||||
global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [req.decoded.port]).then(function (rows) {
|
||||
global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [req.body.port]).then(function (rows) {
|
||||
if (rows.length !== 0) {
|
||||
return "Port already exists with that port number.";
|
||||
}
|
||||
if (req.decoded.diff > global.config.pool.maxDifficulty || req.decoded.diff < global.config.pool.minDifficulty) {
|
||||
if (req.body.diff > global.config.pool.maxDifficulty || req.body.diff < global.config.pool.minDifficulty) {
|
||||
return "Invalid difficulty.";
|
||||
}
|
||||
if (["pplns", "solo", "pps"].indexOf(req.decoded.portType) === -1) {
|
||||
if (["pplns", "solo", "pps"].indexOf(req.body.portType) === -1) {
|
||||
return "Invalid port type";
|
||||
}
|
||||
global.mysql.query("INSERT INTO port_config (poolPort, difficulty, portDesc, portType, hidden, ssl) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
[req.decoded.port, req.decoded.diff, req.decoded.desc, req.decoded.portType, req.decoded.hidden === 1, req.decoded.ssl === 1]);
|
||||
[req.body.port, req.body.diff, req.body.desc, req.body.portType, req.body.hidden === 1, req.body.ssl === 1]);
|
||||
}).then(function (err) {
|
||||
if (typeof(err) === 'string') {
|
||||
return res.json({success: false, msg: err});
|
||||
@@ -800,19 +800,19 @@ adminRoutes.post('/ports', function (req, res) {
|
||||
});
|
||||
|
||||
adminRoutes.put('/ports', function (req, res) {
|
||||
let portNumber = Number(req.decoded.portNum);
|
||||
let portNumber = Number(req.body.portNum);
|
||||
global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [portNumber]).then(function (rows) {
|
||||
if (rows.length === 0) {
|
||||
return "Port doesn't exist in the database";
|
||||
}
|
||||
if (req.decoded.diff > global.config.pool.maxDifficulty || req.decoded.diff < global.config.pool.minDifficulty) {
|
||||
if (req.body.diff > global.config.pool.maxDifficulty || req.body.diff < global.config.pool.minDifficulty) {
|
||||
return "Invalid difficulty.";
|
||||
}
|
||||
if (["pplns", "solo", "pps"].indexOf(req.decoded.portType) === -1) {
|
||||
if (["pplns", "solo", "pps"].indexOf(req.body.portType) === -1) {
|
||||
return "Invalid port type";
|
||||
}
|
||||
global.mysql.query("UPDATE port_config SET difficulty=?, portDesc=?, portType=?, hidden=?, ssl=? WHERE poolPort = ?",
|
||||
[req.decoded.diff, req.decoded.desc, req.decoded.portType, req.decoded.hidden === 1, req.decoded.ssl === 1, portNumber]);
|
||||
[req.body.diff, req.body.desc, req.body.portType, req.body.hidden === 1, req.body.ssl === 1, portNumber]);
|
||||
}).then(function (err) {
|
||||
if (typeof(err) === 'string') {
|
||||
return res.json({success: false, msg: err});
|
||||
@@ -822,7 +822,7 @@ adminRoutes.put('/ports', function (req, res) {
|
||||
});
|
||||
|
||||
adminRoutes.delete('/ports', function (req, res) {
|
||||
let portNumber = Number(req.decoded.portNum);
|
||||
let portNumber = Number(req.body.portNum);
|
||||
global.mysql.query("SELECT * FROM port_config WHERE poolPort = ?", [portNumber]).then(function (rows) {
|
||||
if (rows.length === 0) {
|
||||
return "Port doesn't exist in the database";
|
||||
@@ -855,12 +855,12 @@ adminRoutes.get('/config', function (req, res) {
|
||||
});
|
||||
|
||||
adminRoutes.put('/config', function (req, res) {
|
||||
let configID = Number(req.decoded.id);
|
||||
let configID = Number(req.body.id);
|
||||
global.mysql.query("SELECT * FROM config WHERE id = ?", [configID]).then(function (rows) {
|
||||
if (rows.length === 0) {
|
||||
return "Config item doesn't exist in the database";
|
||||
}
|
||||
global.mysql.query("UPDATE config SET item_value=? WHERE id = ?", [req.decoded.value, configID]);
|
||||
global.mysql.query("UPDATE config SET item_value=? WHERE id = ?", [req.body.value, configID]);
|
||||
}).then(function (err) {
|
||||
if (typeof(err) === 'string') {
|
||||
return res.json({success: false, msg: err});
|
||||
|
||||
Reference in New Issue
Block a user