summaryrefslogtreecommitdiff
path: root/bucky/app
diff options
context:
space:
mode:
Diffstat (limited to 'bucky/app')
-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()