mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Rename "roles" to "units". Put units in their own folders.
This commit is contained in:
parent
7d9d64ddcb
commit
3a9b193f68
63 changed files with 105 additions and 105 deletions
22
lib/units/websocket/middleware/auth.js
Normal file
22
lib/units/websocket/middleware/auth.js
Normal 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'))
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue