Make channelName optionnal in tests only and validators
Fix tests channel displayName Make channelName in createUser optionnal on server side to not break api Fix auto channelName with createUser in tests
This commit is contained in:
parent
69db147043
commit
766d13b447
|
@ -56,7 +56,7 @@ const usersAddValidator = [
|
||||||
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
|
body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
|
||||||
body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
|
body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
|
||||||
body('email').isEmail().withMessage('Should have a valid email'),
|
body('email').isEmail().withMessage('Should have a valid email'),
|
||||||
body('channelName').custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
|
body('channelName').optional().custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'),
|
||||||
body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
|
body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
|
||||||
body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
|
body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
|
||||||
body('role')
|
body('role')
|
||||||
|
@ -76,11 +76,7 @@ const usersAddValidator = [
|
||||||
.json({ error: 'You can only create users (and not administrators or moderators)' })
|
.json({ error: 'You can only create users (and not administrators or moderators)' })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req.body.channelName) {
|
if (req.body.channelName) {
|
||||||
return res.status(400)
|
|
||||||
.json({ error: 'Channel name is required.' })
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.body.channelName === req.body.username) {
|
if (req.body.channelName === req.body.username) {
|
||||||
return res.status(400)
|
return res.status(400)
|
||||||
.json({ error: 'Channel name cannot be the same as user username.' })
|
.json({ error: 'Channel name cannot be the same as user username.' })
|
||||||
|
@ -91,6 +87,7 @@ const usersAddValidator = [
|
||||||
return res.status(409)
|
return res.status(409)
|
||||||
.json({ error: `Channel with name ${req.body.channelName} already exists.` })
|
.json({ error: `Channel with name ${req.body.channelName} already exists.` })
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return next()
|
return next()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue