From e79bdedb819415792eea49de7483885046d2a368 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 14 May 2018 18:54:22 +0200 Subject: change password form working --- bucky/app/bucky.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'bucky/app/bucky.js') diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index f00c296..70cfeec 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -547,6 +547,22 @@ var bucky = module.exports = { } }) }, + ensureUserFromBody: function (req, res, next){ + var username = util.sanitizeName(req.body.username) + if (! username) { + return res.sendStatus(404) + } + db.getUserByUsername(username).then(function(user){ + if (user) { + res.user = user + next() + } + else { + console.log('no such user!!') + res.sendStatus(404) + } + }) + }, sanitizeUser: function(req, res, next) { res.user = util.sanitizeUser(res.user) next() -- cgit v1.2.3-70-g09d2