isUserPasswordValid,
isUserVideoQuotaValid,
isUserDisplayNSFWValid,
- isIdOrUUIDValid
+ isIdOrUUIDValid,
+ isUserRoleValid
} from '../../helpers'
import { UserInstance, VideoInstance } from '../../models'
const usersAddValidator = [
- body('username').custom(isUserUsernameValid).withMessage('Should have a valid username'),
+ body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
body('password').custom(isUserPasswordValid).withMessage('Should have a valid password'),
body('email').isEmail().withMessage('Should have a valid email'),
body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
+ body('role').custom(isUserRoleValid).withMessage('Should have a valid role'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersAdd parameters', { parameters: req.body })
param('id').isInt().not().isEmpty().withMessage('Should have a valid id'),
body('email').optional().isEmail().withMessage('Should have a valid email attribute'),
body('videoQuota').optional().custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
+ body('role').optional().custom(isUserRoleValid).withMessage('Should have a valid role'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking usersUpdate parameters', { parameters: req.body })
.then(user => {
if (user) {
return res.status(409)
- .send({ error: 'User already exists.' })
+ .send({ error: 'User with this username of email already exists.' })
.end()
}