Permalink
Browse files

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

  • Loading branch information...
2 parents a6c8d8b + 948ef8a commit 3d03f00d6a38cc9bf6b1b7cede227b781dffb172 @steves steves committed Aug 28, 2011
Showing with 23 additions and 9 deletions.
  1. +16 −2 public/javascripts/twalks.js
  2. +4 −4 server.js
  3. +1 −1 views/_navigation.ejs
  4. +2 −2 views/backbone/_events.ejs
View
18 public/javascripts/twalks.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;
@@ -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;
@@ -437,7 +446,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
8 server.js
@@ -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
2 views/_navigation.ejs
@@ -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>
View
4 views/backbone/_events.ejs
@@ -66,7 +66,7 @@
{% } %}
</span>
{% if (typeof location != 'undefined') { %}
- <div class="img" style="width:150px; height:150px; background:url(http://maps.google.com/maps/api/staticmap?center={{ location }}&zoom=13&size=150x150&sensor=false);"></div>
+ <div class="img" style="width:150px; height:150px; background:url(http://maps.google.com/maps/api/staticmap?center={{ encodeURIComponent(location) }}&zoom=13&size=150x150&sensor=false);"></div>
{% } else { %}
<div class="img" style="width:150px; height:150px; background:url(http://maps.google.com/maps/api/staticmap?center=Unknown&zoom=13&size=150x150&sensor=false);"></div>
{% } %}
@@ -124,7 +124,7 @@
<article>
<header class="map">
{% if (typeof location != 'undefined') { %}
- <div class="img" style="width:300px; height:300px; background:url(http://maps.google.com/maps/api/staticmap?center={{ location }}&markers=size:mid|color:blue|{{ location }}&zoom=13&size=300x300&sensor=false);"></div>
+ <div class="img" style="width:300px; height:300px; background:url(http://maps.google.com/maps/api/staticmap?center={{ encodeURIComponent(location) }}&markers=size:mid|color:blue|{{ encodeURIComponent(location) }}&zoom=13&size=300x300&sensor=false);"></div>
{% } else { %}
<div class="img" style="width:300px; height:300px; background:url(http://maps.google.com/maps/api/staticmap?center=Unknown&markers=size:mid|color:blue|Unknown&zoom=13&size=300x300&sensor=false);"></div>
{% } %}

0 comments on commit 3d03f00

Please sign in to comment.