diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-15 15:41:56 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 503c6f440abc8f5924c38c4bd63591cb6cefacec (patch) | |
tree | f369e338d3f6c4c0af574b234b8c53d368350fa5 /server/middlewares/validators | |
parent | 30ff39e7f07898ebb716c938123825c678b4e5af (diff) | |
download | PeerTube-503c6f440abc8f5924c38c4bd63591cb6cefacec.tar.gz PeerTube-503c6f440abc8f5924c38c4bd63591cb6cefacec.tar.zst PeerTube-503c6f440abc8f5924c38c4bd63591cb6cefacec.zip |
Add peertube plugin index website models
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/config.ts | 5 | ||||
-rw-r--r-- | server/middlewares/validators/users.ts | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 31b131914..9c43da165 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts | |||
@@ -5,7 +5,8 @@ import { logger } from '../../helpers/logger' | |||
5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' |
6 | import { Emailer } from '../../lib/emailer' | 6 | import { Emailer } from '../../lib/emailer' |
7 | import { areValidationErrors } from './utils' | 7 | import { areValidationErrors } from './utils' |
8 | import { isThemeValid } from '../../helpers/custom-validators/plugins' | 8 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' |
9 | import { isThemeRegistered } from '../../lib/plugins/theme-utils' | ||
9 | 10 | ||
10 | const customConfigUpdateValidator = [ | 11 | const customConfigUpdateValidator = [ |
11 | body('instance.name').exists().withMessage('Should have a valid instance name'), | 12 | body('instance.name').exists().withMessage('Should have a valid instance name'), |
@@ -48,7 +49,7 @@ const customConfigUpdateValidator = [ | |||
48 | body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), | 49 | body('followers.instance.enabled').isBoolean().withMessage('Should have a valid followers of instance boolean'), |
49 | body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), | 50 | body('followers.instance.manualApproval').isBoolean().withMessage('Should have a valid manual approval boolean'), |
50 | 51 | ||
51 | body('theme.default').custom(isThemeValid).withMessage('Should have a valid theme'), | 52 | body('theme.default').custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), |
52 | 53 | ||
53 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 54 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
54 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) | 55 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index df7f77b84..a507afc5b 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -28,7 +28,8 @@ import { ActorModel } from '../../models/activitypub/actor' | |||
28 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' | 28 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' |
29 | import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' | 29 | import { isVideoChannelNameValid } from '../../helpers/custom-validators/video-channels' |
30 | import { UserRegister } from '../../../shared/models/users/user-register.model' | 30 | import { UserRegister } from '../../../shared/models/users/user-register.model' |
31 | import { isThemeValid } from '../../helpers/custom-validators/plugins' | 31 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' |
32 | import { isThemeRegistered } from '../../lib/plugins/theme-utils' | ||
32 | 33 | ||
33 | const usersAddValidator = [ | 34 | const usersAddValidator = [ |
34 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), | 35 | body('username').custom(isUserUsernameValid).withMessage('Should have a valid username (lowercase alphanumeric characters)'), |
@@ -207,7 +208,7 @@ const usersUpdateMeValidator = [ | |||
207 | .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), | 208 | .custom(isUserVideosHistoryEnabledValid).withMessage('Should have a valid videos history enabled attribute'), |
208 | body('theme') | 209 | body('theme') |
209 | .optional() | 210 | .optional() |
210 | .custom(isThemeValid).withMessage('Should have a valid theme'), | 211 | .custom(v => isThemeNameValid(v) && isThemeRegistered(v)).withMessage('Should have a valid theme'), |
211 | 212 | ||
212 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { | 213 | async (req: express.Request, res: express.Response, next: express.NextFunction) => { |
213 | logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') }) | 214 | logger.debug('Checking usersUpdateMe parameters', { parameters: omit(req.body, 'password') }) |