summaryrefslogtreecommitdiff
path: root/bucky/util/auth.js
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/util/auth.js')
-rw-r--r--bucky/util/auth.js13
1 files changed, 13 insertions, 0 deletions
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!!