diff options
author | Josh Morel <morel.josh@hotmail.com> | 2019-02-17 13:14:00 -0500 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-02-18 17:21:41 +0100 |
commit | 576ad67aaccf713b2a923deb3cb9b2a990613985 (patch) | |
tree | 2feec6798bfe14aa25e73ddce653d06f3f41c7af /server/middlewares/validators | |
parent | 41d713446c2152d47943ddb0c841a9e36ca5a9db (diff) | |
download | PeerTube-576ad67aaccf713b2a923deb3cb9b2a990613985.tar.gz PeerTube-576ad67aaccf713b2a923deb3cb9b2a990613985.tar.zst PeerTube-576ad67aaccf713b2a923deb3cb9b2a990613985.zip |
check email enabled for requiresEmailVer config
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/config.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/server/middlewares/validators/config.ts b/server/middlewares/validators/config.ts index 90108fa82..270ce66f6 100644 --- a/server/middlewares/validators/config.ts +++ b/server/middlewares/validators/config.ts | |||
@@ -2,6 +2,8 @@ import * as express from 'express' | |||
2 | import { body } from 'express-validator/check' | 2 | import { body } from 'express-validator/check' |
3 | import { isUserNSFWPolicyValid, isUserVideoQuotaValid, isUserVideoQuotaDailyValid } from '../../helpers/custom-validators/users' | 3 | import { isUserNSFWPolicyValid, isUserVideoQuotaValid, isUserVideoQuotaDailyValid } from '../../helpers/custom-validators/users' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' | ||
6 | import { Emailer } from '../../lib/emailer' | ||
5 | import { areValidationErrors } from './utils' | 7 | import { areValidationErrors } from './utils' |
6 | 8 | ||
7 | const customConfigUpdateValidator = [ | 9 | const customConfigUpdateValidator = [ |
@@ -46,11 +48,27 @@ const customConfigUpdateValidator = [ | |||
46 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) | 48 | logger.debug('Checking customConfigUpdateValidator parameters', { parameters: req.body }) |
47 | 49 | ||
48 | if (areValidationErrors(req, res)) return | 50 | if (areValidationErrors(req, res)) return |
51 | if (!checkInvalidConfigIfEmailDisabled(req.body as CustomConfig, res)) return | ||
49 | 52 | ||
50 | return next() | 53 | return next() |
51 | } | 54 | } |
52 | ] | 55 | ] |
53 | 56 | ||
57 | // --------------------------------------------------------------------------- | ||
58 | |||
54 | export { | 59 | export { |
55 | customConfigUpdateValidator | 60 | customConfigUpdateValidator |
56 | } | 61 | } |
62 | |||
63 | function checkInvalidConfigIfEmailDisabled (customConfig: CustomConfig, res: express.Response) { | ||
64 | if (Emailer.isEnabled()) return true | ||
65 | |||
66 | if (customConfig.signup.requiresEmailVerification === true) { | ||
67 | res.status(400) | ||
68 | .send({ error: 'Emailer is disabled but you require signup email verification.' }) | ||
69 | .end() | ||
70 | return false | ||
71 | } | ||
72 | |||
73 | return true | ||
74 | } | ||