diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-23 17:42:56 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-23 17:42:56 +0200 |
commit | bf68dd752d6e3d5fce791dd8e0df9debb9d96902 (patch) | |
tree | 867e4bef8481b85e81193342922ec60430029838 /server/middlewares/validators | |
parent | de59c48f5f317018e3f746bbe4a7b7efe00109f2 (diff) | |
download | PeerTube-bf68dd752d6e3d5fce791dd8e0df9debb9d96902.tar.gz PeerTube-bf68dd752d6e3d5fce791dd8e0df9debb9d96902.tar.zst PeerTube-bf68dd752d6e3d5fce791dd8e0df9debb9d96902.zip |
Client: fix error display for component
Diffstat (limited to 'server/middlewares/validators')
-rw-r--r-- | server/middlewares/validators/users.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/server/middlewares/validators/users.js b/server/middlewares/validators/users.js index e540ab0d1..5defdf4e3 100644 --- a/server/middlewares/validators/users.js +++ b/server/middlewares/validators/users.js | |||
@@ -17,11 +17,20 @@ function usersAdd (req, res, next) { | |||
17 | req.checkBody('username', 'Should have a valid username').isUserUsernameValid() | 17 | req.checkBody('username', 'Should have a valid username').isUserUsernameValid() |
18 | req.checkBody('password', 'Should have a valid password').isUserPasswordValid() | 18 | req.checkBody('password', 'Should have a valid password').isUserPasswordValid() |
19 | 19 | ||
20 | // TODO: check we don't have already the same username | ||
21 | |||
22 | logger.debug('Checking usersAdd parameters', { parameters: req.body }) | 20 | logger.debug('Checking usersAdd parameters', { parameters: req.body }) |
23 | 21 | ||
24 | checkErrors(req, res, next) | 22 | checkErrors(req, res, function () { |
23 | User.loadByUsername(req.body.username, function (err, user) { | ||
24 | if (err) { | ||
25 | logger.error('Error in usersAdd request validator.', { error: err }) | ||
26 | return res.sendStatus(500) | ||
27 | } | ||
28 | |||
29 | if (user) return res.status(409).send('User already exists.') | ||
30 | |||
31 | next() | ||
32 | }) | ||
33 | }) | ||
25 | } | 34 | } |
26 | 35 | ||
27 | function usersRemove (req, res, next) { | 36 | function usersRemove (req, res, next) { |