mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-26 11:11:43 +00:00
Simplify user delete checks
This commit is contained in:
parent
bced308462
commit
f12abca3fc
1 changed files with 4 additions and 8 deletions
|
|
@ -365,18 +365,14 @@ class UserController {
|
||||||
async delete(req, res) {
|
async delete(req, res) {
|
||||||
const user = req.reqUser
|
const user = req.reqUser
|
||||||
|
|
||||||
if (user.isRoot && !req.user.isRoot) {
|
|
||||||
Logger.error(`[UserController] Admin user "${req.user.username}" attempted to delete root user`)
|
|
||||||
return res.sendStatus(403)
|
|
||||||
}
|
|
||||||
if (user.isRoot) {
|
|
||||||
Logger.error('[UserController] Attempt to delete root user. Root user cannot be deleted')
|
|
||||||
return res.sendStatus(400)
|
|
||||||
}
|
|
||||||
if (req.user.id === req.params.id) {
|
if (req.user.id === req.params.id) {
|
||||||
Logger.error(`[UserController] User ${req.user.username} is attempting to delete self`)
|
Logger.error(`[UserController] User ${req.user.username} is attempting to delete self`)
|
||||||
return res.sendStatus(400)
|
return res.sendStatus(400)
|
||||||
}
|
}
|
||||||
|
if (user.isRoot) {
|
||||||
|
Logger.error(`[UserController] Admin user "${req.user.username}" attempted to delete root user`)
|
||||||
|
return res.sendStatus(403)
|
||||||
|
}
|
||||||
|
|
||||||
// Todo: check if user is logged in and cancel streams
|
// Todo: check if user is logged in and cancel streams
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue