summaryrefslogtreecommitdiff
path: root/lib/response.js
diff options
context:
space:
mode:
authorPedro Ferreira2018-03-26 14:58:25 +0200
committerPedro Ferreira2018-03-27 08:53:37 +0200
commit99abac343bd098ea032cac8e5b703193ad41d069 (patch)
treea58b52f86c7dd7d09793df7ce42b331235064b7b /lib/response.js
parent5d57a4bb6f126e327d576d34e489d479326fb4e2 (diff)
403: redirect user to login page if not logged in
Signed-Off-By: Pedro Ferreira <pedro.ferreira@cern.ch>
Diffstat (limited to 'lib/response.js')
-rw-r--r--lib/response.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/response.js b/lib/response.js
index b18fd7a3..aeb594a3 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -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.')