Skip to content

Commit

Permalink
assignpos and isbanned endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Ianyourgod committed Mar 4, 2024
1 parent ef9a3e9 commit 2e1296e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions api/v1/routes/users/assignPossition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = (app, utils) => {
app.get('/api/v1/users/assignPossition', async function (req, res) {
const packet = req.query;
if (!await utils.UserManager.loginWithToken(packet.user, packet.token)) {
utils.error(res, 400, "Reauthenticate");
return;
}
if (!await utils.UserManager.isAdmin(packet.user)) {
utils.error(res, 403, "FeatureDisabledForThisAccount");
return;
}

await utils.UserManager.setAdmin(packet.target, utils.Cast.toBoolean(packet.admin));
await utils.UserManager.setApprover(packet.target, utils.Cast.toBoolean(packet.approver));

res.status(200);
res.header("Content-Type", 'application/json');
res.json({ "success": 'AppliedStatus' });
});
}
12 changes: 12 additions & 0 deletions api/v1/routes/users/isBanned.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = (app, utils) => {
app.get('/api/v1/users/isBanned', async function (req, res) {
if (typeof req.query.username != "string") {
utils.error(res, 400, "InvalidRequest");
return;
}

res.status(200);
res.header("Content-Type", 'application/json');
res.json({ "banned": await utils.UserManager.isBanned(req.query.username) });
});
}

0 comments on commit 2e1296e

Please sign in to comment.