aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/users.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-05 13:54:35 +0200
committerChocobozzz <me@florianbigard.com>2021-08-05 13:54:35 +0200
commit27db78400c558e19bfac0da885fe0b7d0a3e6a0c (patch)
treee50e031f4b0989e438f3c1610c0a16086dd9455f /server/middlewares/validators/users.ts
parent352819ef921e45381b3fbb17072926103b320e73 (diff)
downloadPeerTube-27db78400c558e19bfac0da885fe0b7d0a3e6a0c.tar.gz
PeerTube-27db78400c558e19bfac0da885fe0b7d0a3e6a0c.tar.zst
PeerTube-27db78400c558e19bfac0da885fe0b7d0a3e6a0c.zip
Fix backend channel name validator consistency
Diffstat (limited to 'server/middlewares/validators/users.ts')
-rw-r--r--server/middlewares/validators/users.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 748b89f8f..bc8607523 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -6,7 +6,6 @@ import { MUserDefault } from '@server/types/models'
6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' 6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
7import { UserRole } from '../../../shared/models/users' 7import { UserRole } from '../../../shared/models/users'
8import { UserRegister } from '../../../shared/models/users/user-register.model' 8import { UserRegister } from '../../../shared/models/users/user-register.model'
9import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
10import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' 9import { toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
11import { isThemeNameValid } from '../../helpers/custom-validators/plugins' 10import { isThemeNameValid } from '../../helpers/custom-validators/plugins'
12import { 11import {
@@ -28,7 +27,7 @@ import {
28 isUserVideoQuotaValid, 27 isUserVideoQuotaValid,
29 isUserVideosHistoryEnabledValid 28 isUserVideosHistoryEnabledValid
30} from '../../helpers/custom-validators/users' 29} from '../../helpers/custom-validators/users'
31import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' 30import { isVideoChannelDisplayNameValid, isVideoChannelUsernameValid } from '../../helpers/custom-validators/video-channels'
32import { logger } from '../../helpers/logger' 31import { logger } from '../../helpers/logger'
33import { isThemeRegistered } from '../../lib/plugins/theme-utils' 32import { isThemeRegistered } from '../../lib/plugins/theme-utils'
34import { Redis } from '../../lib/redis' 33import { Redis } from '../../lib/redis'
@@ -56,9 +55,12 @@ const usersAddValidator = [
56 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), 55 body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'),
57 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'), 56 body('password').custom(isUserPasswordValidOrEmpty).withMessage('Should have a valid password'),
58 body('email').isEmail().withMessage('Should have a valid email'), 57 body('email').isEmail().withMessage('Should have a valid email'),
59 body('channelName').optional().custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), 58
59 body('channelName').optional().custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
60
60 body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'), 61 body('videoQuota').custom(isUserVideoQuotaValid).withMessage('Should have a valid user quota'),
61 body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'), 62 body('videoQuotaDaily').custom(isUserVideoQuotaDailyValid).withMessage('Should have a valid daily user quota'),
63
62 body('role') 64 body('role')
63 .customSanitizer(toIntOrNull) 65 .customSanitizer(toIntOrNull)
64 .custom(isUserRoleValid).withMessage('Should have a valid role'), 66 .custom(isUserRoleValid).withMessage('Should have a valid role'),
@@ -106,10 +108,10 @@ const usersRegisterValidator = [
106 108
107 body('channel.name') 109 body('channel.name')
108 .optional() 110 .optional()
109 .custom(isActorPreferredUsernameValid).withMessage('Should have a valid channel name'), 111 .custom(isVideoChannelUsernameValid).withMessage('Should have a valid channel name'),
110 body('channel.displayName') 112 body('channel.displayName')
111 .optional() 113 .optional()
112 .custom(isVideoChannelNameValid).withMessage('Should have a valid display name'), 114 .custom(isVideoChannelDisplayNameValid).withMessage('Should have a valid display name'),
113 115
114 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 116 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
115 logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') }) 117 logger.debug('Checking usersRegister parameters', { parameters: omit(req.body, 'password') })