From 68a3b9f2aacb0225ae8b883b561b144bac339cbd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 9 Aug 2016 21:44:45 +0200 Subject: Server: delete user with the id and not the username --- server/middlewares/validators/users.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'server/middlewares') diff --git a/server/middlewares/validators/users.js b/server/middlewares/validators/users.js index 175d90bcb..e540ab0d1 100644 --- a/server/middlewares/validators/users.js +++ b/server/middlewares/validators/users.js @@ -25,12 +25,12 @@ function usersAdd (req, res, next) { } function usersRemove (req, res, next) { - req.checkParams('username', 'Should have a valid username').isUserUsernameValid() + req.checkParams('id', 'Should have a valid id').notEmpty().isMongoId() logger.debug('Checking usersRemove parameters', { parameters: req.params }) checkErrors(req, res, function () { - User.loadByUsername(req.params.username, function (err, user) { + User.loadById(req.params.id, function (err, user) { if (err) { logger.error('Error in usersRemove request validator.', { error: err }) return res.sendStatus(500) @@ -44,6 +44,7 @@ function usersRemove (req, res, next) { } function usersUpdate (req, res, next) { + req.checkParams('id', 'Should have a valid id').notEmpty().isMongoId() // Add old password verification req.checkBody('password', 'Should have a valid password').isUserPasswordValid() -- cgit v1.2.3