Ensure that each request has a corresponding user in the database.

This commit is contained in:
Simo Kinnunen
2014-02-03 14:23:05 +09:00
parent b84968c08c
commit 59178ee837
2 changed files with 21 additions and 5 deletions

View File

@@ -92,7 +92,7 @@ module.exports = function(options) {
app.get('/api/v1/user', function(req, res) {
res.json({
success: true
, user: req.session.jwt
, user: req.user
})
})
@@ -147,8 +147,13 @@ module.exports = function(options) {
handshake.session = handshake.signedCookies[options.ssid]
return dbapi.loadUser(handshake.session.jwt.email)
.then(function(user) {
handshake.user = user
accept(null, true)
if (user) {
handshake.user = user
accept(null, true)
}
else {
accept(null, false)
}
})
}
else {