1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +02:00

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

@ -24,8 +24,19 @@ module.exports = function(options) {
}
}
else if (req.session && req.session.jwt) {
// Continue existing session
next()
dbapi.loadUser(req.session.jwt.email)
.then(function(user) {
if (user) {
// Continue existing session
req.user = user
next()
}
else {
// We no longer have the user in the database
res.redirect(options.authUrl)
}
})
.catch(next)
}
else {
// No session, forward to auth client