aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/middlewares/validators/users.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 423da9bc0..aff18be3d 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -56,6 +56,7 @@ const usersAddValidator = [
56 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), 56 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
57 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'), 57 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
58 body('email').isEmail().withMessage('Should have a valid email'), 58 body('email').isEmail().withMessage('Should have a valid email'),
59 body('channelName').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
59 body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'), 60 body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
60 body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), 61 body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
61 body('role') 62 body('role')
@@ -75,6 +76,22 @@ const usersAddValidator = [
75 .json({ error: 'You can only create users (and not administrators or moderators)' }) 76 .json({ error: 'You can only create users (and not administrators or moderators)' })
76 } 77 }
77 78
79 if (!req.body.channelName) {
80 return res.status(400)
81 .json({ error: 'Channel name is required.' })
82 }
83
84 if (req.body.channelName === req.body.username) {
85 return res.status(400)
86 .json({ error: 'Channel name cannot be the same as user username.' })
87 }
88
89 const existing = await ActorModel.loadLocalByName(req.body.channelName)
90 if (existing) {
91 return res.status(409)
92 .json({ error: `Channel with name ${req.body.channelName} already exists.` })
93 }
94
78 return next() 95 return next()
79 } 96 }
80] 97]