diff options
| author | Pitu <[email protected]> | 2019-03-12 05:48:01 +0000 |
|---|---|---|
| committer | Pitu <[email protected]> | 2019-03-12 05:48:01 +0000 |
| commit | 197e69f2f2194df4ad23bb913c9efd39e1501b96 (patch) | |
| tree | 336f3b45d9626c9b05700bbdcefb0d18168f270a /src/api/routes/admin/userDemote.js | |
| parent | No more infinite loading if album is empty (diff) | |
| download | host.fuwn.me-197e69f2f2194df4ad23bb913c9efd39e1501b96.tar.xz host.fuwn.me-197e69f2f2194df4ad23bb913c9efd39e1501b96.zip | |
Prevent snowflakes from demoting/disabling themselves
Diffstat (limited to 'src/api/routes/admin/userDemote.js')
| -rw-r--r-- | src/api/routes/admin/userDemote.js | 3 |
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') |