aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r--server/middlewares/validators/users.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 8ca9763a1..3c207c81f 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -74,6 +74,19 @@ const usersRemoveValidator = [
74 } 74 }
75] 75]
76 76
77const deleteMeValidator = [
78 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
79 const user: UserModel = res.locals.oauth.token.User
80 if (user.username === 'root') {
81 return res.status(400)
82 .send({ error: 'You cannot delete your root account.' })
83 .end()
84 }
85
86 return next()
87 }
88]
89
77const usersUpdateValidator = [ 90const usersUpdateValidator = [
78 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'), 91 param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
79 body('email').optional().isEmail().withMessage('Should have a valid email attribute'), 92 body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
@@ -215,6 +228,7 @@ const usersResetPasswordValidator = [
215 228
216export { 229export {
217 usersAddValidator, 230 usersAddValidator,
231 deleteMeValidator,
218 usersRegisterValidator, 232 usersRegisterValidator,
219 usersRemoveValidator, 233 usersRemoveValidator,
220 usersUpdateValidator, 234 usersUpdateValidator,