diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-25 17:48:51 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-25 17:48:51 +0200 |
commit | ba44fa19531186944fef3e9da34f5e91f0c0dedb (patch) | |
tree | ec00417ee5b1113235b0dda98972a30ec697b967 /server/middlewares | |
parent | 0a381679e04bc7adf097da9a6fb4e2c8f41bbda2 (diff) | |
download | PeerTube-ba44fa19531186944fef3e9da34f5e91f0c0dedb.tar.gz PeerTube-ba44fa19531186944fef3e9da34f5e91f0c0dedb.tar.zst PeerTube-ba44fa19531186944fef3e9da34f5e91f0c0dedb.zip |
Move ensureRegistrationEnabled to middlewares
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/config.ts | 20 | ||||
-rw-r--r-- | server/middlewares/index.ts | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/server/middlewares/config.ts b/server/middlewares/config.ts new file mode 100644 index 000000000..1481e66cc --- /dev/null +++ b/server/middlewares/config.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import 'express-validator' | ||
2 | import * as express from 'express' | ||
3 | |||
4 | import { CONFIG } from '../initializers' | ||
5 | |||
6 | function ensureUserRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
7 | const registrationEnabled = CONFIG.SIGNUP.ENABLED | ||
8 | |||
9 | if (registrationEnabled === true) { | ||
10 | return next() | ||
11 | } | ||
12 | |||
13 | return res.status(400).send('User registration is not enabled.') | ||
14 | } | ||
15 | |||
16 | // --------------------------------------------------------------------------- | ||
17 | |||
18 | export { | ||
19 | ensureUserRegistrationEnabled | ||
20 | } | ||
diff --git a/server/middlewares/index.ts b/server/middlewares/index.ts index d71dd2452..9a3f849a7 100644 --- a/server/middlewares/index.ts +++ b/server/middlewares/index.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | export * from './validators' | 1 | export * from './validators' |
2 | export * from './admin' | 2 | export * from './admin' |
3 | export * from './config' | ||
3 | export * from './oauth' | 4 | export * from './oauth' |
4 | export * from './pagination' | 5 | export * from './pagination' |
5 | export * from './pods' | 6 | export * from './pods' |