Skip to content
Snippets Groups Projects
Commit a9801d85 authored by Haidar's avatar Haidar
Browse files

fix: error validation

parent a035e675
Branches
Tags
No related merge requests found
...@@ -13,13 +13,14 @@ exports.updatePoints = (req, res) => { ...@@ -13,13 +13,14 @@ exports.updatePoints = (req, res) => {
// const query = "UPDATE users SET points = points + ? WHERE username = ?"; // const query = "UPDATE users SET points = points + ? WHERE username = ?";
let username = req.username; let username = req.username;
const amounts = req.body.amount; const amounts = req.body.amount;
if (typeof amounts !== 'number' || !Number.isInteger(amounts) || amounts > 1000000 || amounts < 0) { // if (typeof amounts !== 'number' || !Number.isInteger(amounts) || amounts > 1000000 || amounts < 0) {
res.json({ success: false, message: "Invalid amount" }); // res.json({ success: false, message: "Invalid amount" });
return; // return;
} // }
console.log(req.body.amount)
const query = 'SELECT * FROM users WHERE username = ?'; const query = 'SELECT * FROM users WHERE username = ?';
con.query(query, [username], function (err, results){ con.query(query, [username], function (err, results){
if (err) { if (err) {
...@@ -29,6 +30,7 @@ exports.updatePoints = (req, res) => { ...@@ -29,6 +30,7 @@ exports.updatePoints = (req, res) => {
if (results.length > 0) { if (results.length > 0) {
const userId = results[0].id; const userId = results[0].id;
const email = results[0].email; const email = results[0].email;
// console.log(userId);
const xml = util.format(topup.template, userId, req.body.amount, email); const xml = util.format(topup.template, userId, req.body.amount, email);
axios.post(topup.url, xml, { axios.post(topup.url, xml, {
headers: topup.headers headers: topup.headers
......
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