14 lines
475 B
JavaScript
14 lines
475 B
JavaScript
export function authGuard(req, res, next) {
|
|
const { userInfos, authenticated } = req.session || {}
|
|
if (!userInfos || !authenticated) {
|
|
let jsonResp = {'success':false,
|
|
'payload': null,
|
|
'error': {
|
|
'displayMessage' : 'Please login first !',
|
|
'debugMessage' : 'No session or unauthorized one.'
|
|
}
|
|
}
|
|
return res.status(401).json(jsonResp)
|
|
}
|
|
next()
|
|
} |