Permalink
Browse files

store only essential user info in session

This is to prevent the session cookie from going too big

This is a cherry-pick of 766f74e
  • Loading branch information...
1 parent c1a2d86 commit 91f3bf53905bc29f8dc868110504fceccabc7fb6 @mislav committed Oct 27, 2010
Showing with 11 additions and 1 deletion.
  1. +11 −1 lib/twitter/login.rb
View
@@ -101,7 +101,7 @@ def handle_twitter_authorization(request)
response = access_token.get('/1/account/verify_credentials.json')
# get and store authenticated user's info from Twitter
- request.session[:twitter_user] = Yajl::Parser.parse response.body
+ request.session[:twitter_user] = user_hash_from_response(response)
# pass the request down to the main app
response = begin
@@ -155,4 +155,14 @@ def oauth
:authorize_path => '/oauth/authenticate'
)
end
+
+ def user_hash_from_response(api_response)
+ parse_response(api_response).reject { |key, _|
+ key == 'status' or key =~ /^profile_|_color$/
+ }
+ end
+
+ def parse_response(api_response)
+ Yajl::Parser.parse api_response.body
+ end
end

0 comments on commit 91f3bf5

Please sign in to comment.