aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-25 17:48:51 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-25 17:48:51 +0200
commitba44fa19531186944fef3e9da34f5e91f0c0dedb (patch)
treeec00417ee5b1113235b0dda98972a30ec697b967 /server/controllers/api/users.ts
parent0a381679e04bc7adf097da9a6fb4e2c8f41bbda2 (diff)
downloadPeerTube-ba44fa19531186944fef3e9da34f5e91f0c0dedb.tar.gz
PeerTube-ba44fa19531186944fef3e9da34f5e91f0c0dedb.tar.zst
PeerTube-ba44fa19531186944fef3e9da34f5e91f0c0dedb.zip
Move ensureRegistrationEnabled to middlewares
Diffstat (limited to 'server/controllers/api/users.ts')
-rw-r--r--server/controllers/api/users.ts13
1 files changed, 2 insertions, 11 deletions
diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts
index 1e9e65689..ce15353ef 100644
--- a/server/controllers/api/users.ts
+++ b/server/controllers/api/users.ts
@@ -7,6 +7,7 @@ import { logger, getFormatedObjects } from '../../helpers'
7import { 7import {
8 authenticate, 8 authenticate,
9 ensureIsAdmin, 9 ensureIsAdmin,
10 ensureUserRegistrationEnabled,
10 usersAddValidator, 11 usersAddValidator,
11 usersUpdateValidator, 12 usersUpdateValidator,
12 usersRemoveValidator, 13 usersRemoveValidator,
@@ -48,7 +49,7 @@ usersRouter.post('/',
48) 49)
49 50
50usersRouter.post('/register', 51usersRouter.post('/register',
51 ensureRegistrationEnabled, 52 ensureUserRegistrationEnabled,
52 usersAddValidator, 53 usersAddValidator,
53 createUser 54 createUser
54) 55)
@@ -77,16 +78,6 @@ export {
77 78
78// --------------------------------------------------------------------------- 79// ---------------------------------------------------------------------------
79 80
80function ensureRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) {
81 const registrationEnabled = CONFIG.SIGNUP.ENABLED
82
83 if (registrationEnabled === true) {
84 return next()
85 }
86
87 return res.status(400).send('User registration is not enabled.')
88}
89
90function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { 81function createUser (req: express.Request, res: express.Response, next: express.NextFunction) {
91 const user = db.User.build({ 82 const user = db.User.build({
92 username: req.body.username, 83 username: req.body.username,