2024-03-05 10:20:36 +00:00

23 lines
524 B
JavaScript
Executable File

export default function (req, res, next) {
// extract authentification header
let auth = req.headers.authorization
if (!auth) {
return next()
}
auth = req.sessionToken = auth.replace("Bearer ", "")
// check if authentification is valid
comty.rest.session.validateToken(auth)
.catch((error) => {
return {
valid: false,
}
})
.then((validation) => {
req.session = validation.data
next()
})
}