1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Move ensureRegistrationEnabled to middlewares

This commit is contained in:
Chocobozzz 2017-06-25 17:48:51 +02:00
parent 0a381679e0
commit ba44fa1953
3 changed files with 23 additions and 11 deletions

View file

@ -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,