Skip to content
Browse files

dealing with mangled JSON

  • Loading branch information...
1 parent b5540cc commit 54506fcb2803e11fa47bba1454857377bd1e38ac @denniscollective denniscollective committed Aug 31, 2010
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/facebook_connect.rb
View
5 lib/facebook_connect.rb
@@ -15,8 +15,9 @@ def valid?
def authenticate!
fail!('unauthenticated') unless signature_valid?
- facebook_id = facebook_session_cookie['uid']
- user = user_model.where(:uid => facebook_id).first || user_model.load_from_facebook(facebook_session_cookie['access_token'])
+ facebook_id = facebook_session_cookie['uid'].to_i.to_s #mangled json returns id with a hanging double quote, .to_i drops that
+ access_token = facebook_session_cookie['access_token'] || facebook_session_cookie['"access_token'] #hooray for malformed json
+ user = user_model.where(:uid => facebook_id).first || user_model.load_from_facebook(access_token)
success!(user)
end

0 comments on commit 54506fc

Please sign in to comment.
Something went wrong with that request. Please try again.