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:
parent
b84968c08c
commit
59178ee837
2 changed files with 21 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue