Module: AuthlogicFacebookShim::Adapters::KoalaAdapter
- Defined in:
- lib/authlogic_facebook_shim/adapters/koala_adapter.rb
Instance Method Summary collapse
Instance Method Details
#facebook_session ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/authlogic_facebook_shim/adapters/koala_adapter.rb', line 5 def facebook_session @facebook_session ||= begin oauth = Koala::Facebook::OAuth.new(facebook_app_id, facebook_secret_key) if oauth.respond_to?(:get_user_info_from_cookie) user_info = oauth.(controller.) else user_info = oauth.(controller.) end OpenStruct.new( user_info ) if user_info rescue Koala::Facebook::APIError nil end end |
#facebook_session? ⇒ Boolean
20 21 22 |
# File 'lib/authlogic_facebook_shim/adapters/koala_adapter.rb', line 20 def facebook_session? !facebook_session.nil? end |
#facebook_user ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/authlogic_facebook_shim/adapters/koala_adapter.rb', line 24 def facebook_user @facebook_user ||= begin graph_api = Koala::Facebook.const_defined?(:API) ? Koala::Facebook::API : Koala::Facebook::GraphAPI facebook_graph = graph_api.new(facebook_session.access_token) user = facebook_graph.get_object('me') user[:uid] = user.delete('id') OpenStruct.new( user ) end if facebook_session? end |