mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-08-27 13:54:03 +02:00
Simplify user delete checks
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user