Permalink
Browse files

Add unauthorized error messages to event forms and my events pages.

  • Loading branch information...
jmikola committed Aug 28, 2011
1 parent 378ac38 commit b1df4d97c4916bb7bcd12bdc7871036c68313498
Showing with 12 additions and 3 deletions.
  1. +11 −2 public/javascripts/twalks.js
  2. +1 −1 server.js
@@ -295,7 +295,11 @@
window.App.router.navigate('events/' + model.get('_id'), true);
}
, error: function(model, err) {
- console.log(err);
+ if (403 == err.status) {
+ alertMessage('warning', 'You must be signed in to submit this form. Please sign in using the link at the top right.');
+ return;
+ }
+
alertMessage('error', 'Oops! There was a problem submitting this form. Please fix the errors below and try again.');
var errors = $.parseJSON(err.responseText)
, self = this;
@@ -437,7 +441,12 @@
self.displayContainer(listView.render().el);
});
}
- , error: function(){
+ , error: function(model, err){
+ if (403 == err.status) {
+ alertMessage('warning', 'You must be signed in to view your events. Please sign in using the link at the top right.');
+ return;
+ }
+
alertMessage('warning', 'We encountered an error fetching your events.');
}
});
View
@@ -136,7 +136,7 @@ app.get('/', function(req, res){
});
function andRequireUser(req, res, next) {
- req.loggedIn ? next() : next(new Error('Unauthorized'));
+ req.loggedIn ? next() : res.send('Unauthorized', 403);
}
app.post('/events/new.json', andRequireUser, function(req, res){

0 comments on commit b1df4d9

Please sign in to comment.