-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criar uma mensagem de erro para o usuário, informando que ele não est…
…á logado
- Loading branch information
Showing
3 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, '/'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
<% if (req.session.flash) { %> | ||
<% if (req.session.flash.success) { %> | ||
<% for(var i=0; i<req.session.flash.success.length; i++) {%> | ||
<div data-alert class="alert-box success radius"> | ||
<%= req.session.flash.success[i] %> | ||
<a href="#" class="close">×</a> | ||
</div> | ||
<% } %> | ||
<% req.session.flash.success = undefined %> | ||
<% } %> | ||
<% if (req.session.flash.warning) { %> | ||
<% for(var i=0; i<req.session.flash.warning.length; i++) {%> | ||
<div data-alert class="alert-box warning radius"> | ||
<%= req.session.flash.warning[i] %> | ||
<a href="#" class="close">×</a> | ||
</div> | ||
<% } %> | ||
<% req.session.flash.warning = undefined %> | ||
<% } %> | ||
<% if (req.session.flash.error) { %> | ||
<% for(var i=0; i<req.session.flash.error.length; i++) {%> | ||
<div data-alert class="alert-box alert radius"> | ||
<%= req.session.flash.error[i] %> | ||
<a href="#" class="close">×</a> | ||
</div> | ||
<% } %> | ||
<% req.session.flash.error = undefined %> | ||
<% } %> | ||
<% } %> | ||
|