aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/admin/userDemote.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/admin/userDemote.js')
-rw-r--r--src/api/routes/admin/userDemote.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/api/routes/admin/userDemote.js b/src/api/routes/admin/userDemote.js
index fa288fc..b430a48 100644
--- a/src/api/routes/admin/userDemote.js
+++ b/src/api/routes/admin/userDemote.js
@@ -5,10 +5,11 @@ class userDemote extends Route {
super('/admin/users/demote', 'post', { adminOnly: true });
}
- async run(req, res, db) {
+ async run(req, res, db, user) {
if (!req.body) return res.status(400).json({ message: 'No body provided' });
const { id } = req.body;
if (!id) return res.status(400).json({ message: 'No id provided' });
+ if (id === user.id) return res.status(400).json({ message: 'You can\'t apply this action to yourself' });
try {
await db.table('users')