mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
23 lines
524 B
JavaScript
Executable File
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()
|
|
})
|
|
} |