mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Server: add ability to register new user
This commit is contained in:
parent
db216afd98
commit
2c2e909216
5 changed files with 179 additions and 2 deletions
|
@ -44,6 +44,12 @@ router.post('/',
|
|||
createUser
|
||||
)
|
||||
|
||||
router.post('/register',
|
||||
ensureRegistrationEnabled,
|
||||
validatorsUsers.usersAdd,
|
||||
createUser
|
||||
)
|
||||
|
||||
router.put('/:id',
|
||||
oAuth.authenticate,
|
||||
validatorsUsers.usersUpdate,
|
||||
|
@ -66,6 +72,16 @@ module.exports = router
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function ensureRegistrationEnabled (req, res, next) {
|
||||
const registrationEnabled = constants.CONFIG.SIGNUP.ENABLED
|
||||
|
||||
if (registrationEnabled === true) {
|
||||
return next()
|
||||
}
|
||||
|
||||
return res.status(400).send('User registration is not enabled.')
|
||||
}
|
||||
|
||||
function createUser (req, res, next) {
|
||||
const user = db.User.build({
|
||||
username: req.body.username,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue