aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-04-09 12:08:36 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-04-09 12:08:36 +0200
commit2c2e90921646d223060e98d517fc8ac61c90eb9e (patch)
treecc36bfa79f0809e8c9602492788ef95b3521e003 /server/controllers/api
parentdb216afd980846c418a4ebab8190c3ead561dfc1 (diff)
downloadPeerTube-2c2e90921646d223060e98d517fc8ac61c90eb9e.tar.gz
PeerTube-2c2e90921646d223060e98d517fc8ac61c90eb9e.tar.zst
PeerTube-2c2e90921646d223060e98d517fc8ac61c90eb9e.zip
Server: add ability to register new user
Diffstat (limited to 'server/controllers/api')
-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,