Skip to content

Commit 12ab900

Browse files
authored
Merge pull request #785 from pferreir/redirect-to-login
403: Redirect user to login page if not logged in
2 parents a258719 + 99abac3 commit 12ab900

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/response.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ var utils = require('./utils')
1717
// public
1818
var response = {
1919
errorForbidden: function (res) {
20-
responseError(res, '403', 'Forbidden', 'oh no.')
20+
const {req} = res
21+
if (req.user) {
22+
responseError(res, '403', 'Forbidden', 'oh no.')
23+
} else {
24+
req.flash('error', 'You are not allowed to access this page. Maybe try logging in?')
25+
res.redirect(config.serverURL)
26+
}
2127
},
2228
errorNotFound: function (res) {
2329
responseError(res, '404', 'Not Found', 'oops.')

0 commit comments

Comments
 (0)