diff --git a/dbhandler.js b/dbhandler.js index 2aab11f..b780f50 100644 --- a/dbhandler.js +++ b/dbhandler.js @@ -269,8 +269,7 @@ async function getUserBanned(req) { return new Promise((resolve, reject) => { var request = req.body; if (request.input === undefined) { - return reject('Failed to update user ban state, insufficent paramaters') - return + return reject('Failed to update user ban state, insufficent paramaters'); } db.run('UPDATE maimai2_user_detail SET ban_state = ? WHERE id = ?', [2, request.input], function (err) { if (err) { @@ -282,7 +281,18 @@ async function getUserBanned(req) { }); }); } else { - + var con = await establishConnection(); + return new Promise((resolve, reject) => { + var request = req.body; + con.query(`UPDATE aime.mai2_profile_detail SET banState = 2 WHERE user = ${request.input}`, function (err, result, fields) { + if (err) { + reject({ "status": "failure", "message": "Unable to ban user, see reason", "reason": err }) + throw err + }; + con.release(); + resolve({ "status": "Success", "message": `User ${request.input} banned.` }) + }) + }); } } @@ -305,7 +315,18 @@ async function getUserUnbanned(req) { }); }); } else { - + var con = await establishConnection(); + return new Promise((resolve, reject) => { + var request = req.body; + con.query(`UPDATE aime.mai2_profile_detail SET banState = 0 WHERE user = ${request.input}`, function (err, result, fields) { + if (err) { + reject({ "status": "failure", "message": "Unable to ban user, see reason", "reason": err }) + throw err + }; + con.release(); + resolve({ "status": "Success", "message": `User ${request.input} banned.` }) + }) + }); } } diff --git a/public/javascript/user.js b/public/javascript/user.js index 75fd9e2..8146c4d 100644 --- a/public/javascript/user.js +++ b/public/javascript/user.js @@ -223,7 +223,7 @@ async function userPlayLogFormatter(div, loadMoreButton) { errorIncrement++ continue; } - + console.log(song) scoreDiv.innerHTML = `