From 291e8d3eed88fe714fb74ad897ac2c67347a85ff Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 25 Jul 2017 20:17:28 +0200 Subject: Add ability to limit user registrations --- server/controllers/api/config.ts | 15 +++++++++------ server/controllers/api/users.ts | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'server/controllers/api') diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 3e9aa77a5..f02a2bc58 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts @@ -1,6 +1,6 @@ import * as express from 'express' -import { CONFIG } from '../../initializers' +import { isSignupAllowed } from '../../helpers' import { ServerConfig } from '../../../shared' const configRouter = express.Router() @@ -9,12 +9,15 @@ configRouter.get('/', getConfig) // Get the client credentials for the PeerTube front end function getConfig (req: express.Request, res: express.Response, next: express.NextFunction) { - const json: ServerConfig = { - signup: { - enabled: CONFIG.SIGNUP.ENABLED + + isSignupAllowed().then(allowed => { + const json: ServerConfig = { + signup: { + allowed + } } - } - res.json(json) + res.json(json) + }) } // --------------------------------------------------------------------------- diff --git a/server/controllers/api/users.ts b/server/controllers/api/users.ts index 6c375cc5b..f50dbc9a3 100644 --- a/server/controllers/api/users.ts +++ b/server/controllers/api/users.ts @@ -6,7 +6,7 @@ import { logger, getFormatedObjects } from '../../helpers' import { authenticate, ensureIsAdmin, - ensureUserRegistrationEnabled, + ensureUserRegistrationAllowed, usersAddValidator, usersUpdateValidator, usersRemoveValidator, @@ -48,7 +48,7 @@ usersRouter.post('/', ) usersRouter.post('/register', - ensureUserRegistrationEnabled, + ensureUserRegistrationAllowed, usersAddValidator, createUser ) -- cgit v1.2.3