aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/users.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/controllers/api/users.js b/server/controllers/api/users.js
index 6b6c0774f..c7fe7bf85 100644
--- a/server/controllers/api/users.js
+++ b/server/controllers/api/users.js
@@ -44,6 +44,12 @@ router.post('/',
44 createUser 44 createUser
45) 45)
46 46
47router.post('/register',
48 ensureRegistrationEnabled,
49 validatorsUsers.usersAdd,
50 createUser
51)
52
47router.put('/:id', 53router.put('/:id',
48 oAuth.authenticate, 54 oAuth.authenticate,
49 validatorsUsers.usersUpdate, 55 validatorsUsers.usersUpdate,
@@ -66,6 +72,16 @@ module.exports = router
66 72
67// --------------------------------------------------------------------------- 73// ---------------------------------------------------------------------------
68 74
75function ensureRegistrationEnabled (req, res, next) {
76 const registrationEnabled = constants.CONFIG.SIGNUP.ENABLED
77
78 if (registrationEnabled === true) {
79 return next()
80 }
81
82 return res.status(400).send('User registration is not enabled.')
83}
84
69function createUser (req, res, next) { 85function createUser (req, res, next) {
70 const user = db.User.build({ 86 const user = db.User.build({
71 username: req.body.username, 87 username: req.body.username,