Permalink
Browse files

Merge branch 'develop' of github.com:nko2/sf2-boys into develop

  • Loading branch information...
2 parents 08df307 + 3d03f00 commit b2027fc27e99abffdee76726dab557f2ac07282c @everzet committed Aug 28, 2011
Showing with 25 additions and 7 deletions.
  1. +16 −2 public/javascripts/twalks.js
  2. +4 −0 public/stylesheets/style.css
  3. +4 −4 server.js
  4. +1 −1 views/_navigation.ejs
@@ -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;
@@ -353,6 +357,11 @@
});
}
, home: function() {
+ if ($('#navigation .user.menu.loggedIn').length) {
+ this.navigate('events/my', true);
+ return;
+ }
+
$('li.active', this.$navigation).removeClass('active');
var self = this;
@@ -442,7 +451,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.');
}
});
@@ -173,6 +173,10 @@ body {
background: white;
margin: 15px auto;
text-align: center;
+ border-radius:15px;
+ -moz-border-radius:15px;
+ -webkit-border-radius:15px;
+ -o-border-radius:15px;
}
#events-list .list article .time i {
font-weight:bold;
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){
@@ -148,7 +148,7 @@ app.post('/events/new.json', andRequireUser, function(req, res){
, imageUrl: req.body.imageUrl
, location: req.body.location
, description: req.body.description
- , author: req.session.auth.twitter.user.name
+ , author: req.session.auth.twitter.user.screen_name
});
event.save(function(err, model){
@@ -171,7 +171,7 @@ app.put('/events/:id.json', andRequireUser, function(req, res){
schema.Event.findOne({_id: req.params.id}, function(err, event) {
if (err) {
res.send('Can not find event', 404);
- } else if (event.get('author') !== req.session.auth.twitter.user.name) {
+ } else if (event.get('author') !== req.session.auth.twitter.user.screen_name) {
res.send('You have no rights', 403);
} else {
event.set('name' , req.body.name);
@@ -243,7 +243,7 @@ app.get('/events.json', function(req, res){
});
app.get('/events/my.json', andRequireUser, function(req, res) {
- schema.Event.find({author: req.session.auth.twitter.user.name}, function(err, events) {
+ schema.Event.find({author: req.session.auth.twitter.user.screen_name}, function(err, events) {
if (err) {
console.log(err);
res.json({error: true}, 500);
View
@@ -19,7 +19,7 @@
<img src="/images/loading.gif" />
</li>
<% if (everyauth.loggedIn) { %>
- <li class="user menu">
+ <li class="user menu loggedIn">
<a href="javascript:void(0)" class="menu">
<%= everyauth.twitter.user.name %>
</a>

0 comments on commit b2027fc

Please sign in to comment.