Module: AuthlogicFacebookShim::Session::Adapter

Defined in:
lib/authlogic_facebook_shim/session/adapters/koala_adapter.rb

Instance Method Summary collapse

Instance Method Details

#facebook_sessionObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/authlogic_facebook_shim/session/adapters/koala_adapter.rb', line 5

def facebook_session
  @facebook_session ||= begin
    if controller.cookies.has_key?("fbs_#{facebook_app_id}")
      oauth = Koala::Facebook::OAuth.new(facebook_app_id, facebook_secret_key)
      if oauth.respond_to?(:get_user_info_from_cookie)
         = oauth.(controller.cookies)
      else
         = oauth.get_user_from_cookie(controller.cookies)
      end
      OpenStruct.new(  )
    end
  end
end

#facebook_session?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/authlogic_facebook_shim/session/adapters/koala_adapter.rb', line 19

def facebook_session?
  !facebook_session.nil?
end

#facebook_userObject



23
24
25
26
27
28
29
30
# File 'lib/authlogic_facebook_shim/session/adapters/koala_adapter.rb', line 23

def facebook_user
  @facebook_user ||= begin
    facebook_graph = Koala::Facebook::GraphAPI.new(facebook_session.access_token)
    user = facebook_graph.get_object('me')
    user[:uid] = user.delete('id')
    OpenStruct.new( user )
  end if facebook_session?
end