From ba44fa19531186944fef3e9da34f5e91f0c0dedb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 25 Jun 2017 17:48:51 +0200 Subject: Move ensureRegistrationEnabled to middlewares --- server/controllers/api/users.ts | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'server/controllers') 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' import { authenticate, ensureIsAdmin, + ensureUserRegistrationEnabled, usersAddValidator, usersUpdateValidator, usersRemoveValidator, @@ -48,7 +49,7 @@ usersRouter.post('/', ) usersRouter.post('/register', - ensureRegistrationEnabled, + ensureUserRegistrationEnabled, usersAddValidator, createUser ) @@ -77,16 +78,6 @@ export { // --------------------------------------------------------------------------- -function ensureRegistrationEnabled (req: express.Request, res: express.Response, next: express.NextFunction) { - const registrationEnabled = CONFIG.SIGNUP.ENABLED - - if (registrationEnabled === true) { - return next() - } - - return res.status(400).send('User registration is not enabled.') -} - function createUser (req: express.Request, res: express.Response, next: express.NextFunction) { const user = db.User.build({ username: req.body.username, -- cgit v1.2.3