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/util/auth.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'bucky/util/auth.js') diff --git a/bucky/util/auth.js b/bucky/util/auth.js index 624c898..16368cf 100644 --- a/bucky/util/auth.js +++ b/bucky/util/auth.js @@ -163,6 +163,19 @@ var auth = module.exports = { res.user.set('password', newPassword) res.user.save().then(() => next()).catch(err => res.send({ error: err })) }, + changePasswordDangerously: function(req, res, next){ + if (! req.body.password && ! req.body.newpassword) return next() + if (req.body.newpassword !== req.body.newpassword2) { + return res.send({ error: 'Passwords don\'t match.' }) + } + if (! auth.validPassword(req.user, req.body.password)) { + return res.send({ error: 'Password is incorrect.' }) + } + var username = res.user.get('username') + var newPassword = auth.makePassword(username, req.body.newpassword) + res.user.set('password', newPassword) + res.user.save().then(() => next()).catch(err => res.send({ error: err })) + }, verifyLocalUser: function (username, password, done) { // handle passwords!! -- cgit v1.2.3-70-g09d2