403: redirect user to login page if not logged in

Signed-Off-By: Pedro Ferreira <pedro.ferreira@cern.ch>
This commit is contained in:
Pedro Ferreira 2018-03-26 14:58:25 +02:00
parent 5d57a4bb6f
commit 99abac343b

View file

@ -17,7 +17,13 @@ var utils = require('./utils')
// public // public
var response = { var response = {
errorForbidden: function (res) { errorForbidden: function (res) {
responseError(res, '403', 'Forbidden', 'oh no.') const {req} = res
if (req.user) {
responseError(res, '403', 'Forbidden', 'oh no.')
} else {
req.flash('error', 'You are not allowed to access this page. Maybe try logging in?')
res.redirect(config.serverURL)
}
}, },
errorNotFound: function (res) { errorNotFound: function (res) {
responseError(res, '404', 'Not Found', 'oops.') responseError(res, '404', 'Not Found', 'oops.')