summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-14 18:54:22 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-14 18:54:22 +0200
commite79bdedb819415792eea49de7483885046d2a368 (patch)
tree9931fa389c1459347593155dd09a7c2cf3ecc009 /bucky/app/bucky.js
parentafd20e776ba207be9c4a00d29cb61dd3ea760eef (diff)
change password form working
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js16
1 files changed, 16 insertions, 0 deletions
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()