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.

33 lines
590 B

  1. /* global WIKI */
  2. /**
  3. * Authentication middleware
  4. */
  5. module.exports = (req, res, next) => {
  6. // Is user authenticated ?
  7. if (!req.isAuthenticated()) {
  8. if (WIKI.config.public !== true) {
  9. return res.redirect('/login')
  10. } else {
  11. // req.user = rights.guest
  12. res.locals.isGuest = true
  13. }
  14. } else {
  15. res.locals.isGuest = false
  16. }
  17. // Check permissions
  18. // res.locals.rights = rights.check(req)
  19. // if (!res.locals.rights.read) {
  20. // return res.render('error-forbidden')
  21. // }
  22. // Expose user data
  23. res.locals.user = req.user
  24. return next()
  25. }