Merge pull request #785 from pferreir/redirect-to-login

403: Redirect user to login page if not logged in
This commit is contained in:
Christoph (Sheogorath) Kern 2018-05-31 12:16:11 +02:00 committed by GitHub
commit 12ab90020a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,7 +17,13 @@ var utils = require('./utils')
// public
var response = {
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) {
responseError(res, '404', 'Not Found', 'oops.')