mirror of https://github.com/requarks/wiki
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
590 B
34 lines
590 B
/* global WIKI */
|
|
|
|
/**
|
|
* Authentication middleware
|
|
*/
|
|
module.exports = (req, res, next) => {
|
|
// Is user authenticated ?
|
|
|
|
if (!req.isAuthenticated()) {
|
|
if (WIKI.config.public !== true) {
|
|
return res.redirect('/login')
|
|
} else {
|
|
// req.user = rights.guest
|
|
res.locals.isGuest = true
|
|
}
|
|
} else {
|
|
res.locals.isGuest = false
|
|
}
|
|
|
|
// Check permissions
|
|
|
|
// res.locals.rights = rights.check(req)
|
|
|
|
// if (!res.locals.rights.read) {
|
|
// return res.render('error-forbidden')
|
|
// }
|
|
|
|
// Expose user data
|
|
|
|
res.locals.user = req.user
|
|
|
|
return next()
|
|
}
|