diff --git a/api/policies/isAuthenticated.js b/api/policies/isAuthenticated.js index cf84896..11e85b9 100644 --- a/api/policies/isAuthenticated.js +++ b/api/policies/isAuthenticated.js @@ -1,9 +1,13 @@ module.exports = function(req, res, next) { - if (req.isAuthenticated()) { + if (req.isAuthenticated()) { return next(); } - else{ - return res.redirect('/'); - } + + //Chrome bug POST same page twice, so I prefer to override the message + //req.flash('error', 'You are not permitted to perform this action'); + if(!req.session.flash) req.session.flash = {}; + req.session.flash.error = ['You are not permitted to perform this action']; + + return res.redirect(307, '/'); }; \ No newline at end of file diff --git a/views/layout.ejs b/views/layout.ejs index 4c830f0..788ca3a 100644 --- a/views/layout.ejs +++ b/views/layout.ejs @@ -6,7 +6,7 @@ - +