import {
authenticate,
ensureIsAdmin,
+ ensureUserRegistrationEnabled,
usersAddValidator,
usersUpdateValidator,
usersRemoveValidator,
)
usersRouter.post('/register',
- ensureRegistrationEnabled,
+ ensureUserRegistrationEnabled,
usersAddValidator,
createUser
)
// ---------------------------------------------------------------------------
-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,
--- /dev/null
+import 'express-validator'
+import * as express from 'express'
+
+import { CONFIG } from '../initializers'
+
+function ensureUserRegistrationEnabled (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.')
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+ ensureUserRegistrationEnabled
+}