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

Separate websocket to its own role. Necessary because the app was getting pretty big already, but mostly because our Windows PCs don't like to connect to websockets on port 80, which is what we use for the app.

This commit is contained in:
Simo Kinnunen 2014-06-06 15:02:29 +09:00
parent 92be2f1b59
commit 984c45b183
13 changed files with 707 additions and 603 deletions

View file

@ -0,0 +1,22 @@
var dbapi = require('../../../db/api')
module.exports = function(socket, next) {
var req = socket.request
, token = req.session.jwt
if (token) {
return dbapi.loadUser(token.email)
.then(function(user) {
if (user) {
req.user = user
next()
}
else {
next(new Error('Invalid user'))
}
})
.catch(next)
}
else {
next(new Error('Missing authorization token'))
}
}