Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved things around some more for abstracting the adapter

  • Loading branch information...
commit 19c2c1ec655ce3f50288f5360d6384a599984b25 1 parent 01500f9
@james2m authored
View
3  lib/authlogic_facebook_koala.rb
@@ -8,7 +8,8 @@
require 'authlogic_facebook_koala/session/config'
require 'authlogic_facebook_koala/session/adapter'
require 'authlogic_facebook_koala/session/facebook'
- require 'authlogic_facebook_koala/session/base'
+ require 'authlogic_facebook_koala/session'
require 'authlogic_facebook_koala/helper'
+ Authlogic::Session::Base.send :include, AuthlogicFacebookKoala::Session
ActiveRecord::Base.send :include, AuthlogicFacebookKoala::ActsAsAuthentic
end
View
12 lib/authlogic_facebook_koala/session.rb
@@ -0,0 +1,12 @@
+module AuthlogicFacebookKoala
+ module Session
+
+ def self.included(klass)
+ klass.extend Session::Config
+ klass.send(:include, Session::Adapter)
+ klass.send(:include, Session::Facebook)
+ end
+
+ end
+end
+
View
36 lib/authlogic_facebook_koala/session/adapter.rb
@@ -1,35 +1 @@
-module AuthlogicFacebookKoala
- module Session
- module Adapter
-
- 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)
- user_info = oauth.get_user_info_from_cookie(controller.cookies)
- else
- user_info = oauth.get_user_from_cookie(controller.cookies)
- end
- OpenStruct.new( user_info )
- end
- end
- end
-
- def facebook_session?
- !facebook_session.nil?
- end
-
- 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
-
- end
- end
-end
-
+require File.expand_path('adapters/koala_adapter', File.dirname(__FILE__)) if defined?(Koala)
View
35 lib/authlogic_facebook_koala/session/adapters/koala_adapter.rb
@@ -0,0 +1,35 @@
+module AuthlogicFacebookKoala
+ module Session
+ module Adapter
+
+ 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)
+ user_info = oauth.get_user_info_from_cookie(controller.cookies)
+ else
+ user_info = oauth.get_user_from_cookie(controller.cookies)
+ end
+ OpenStruct.new( user_info )
+ end
+ end
+ end
+
+ def facebook_session?
+ !facebook_session.nil?
+ end
+
+ 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
+
+ end
+ end
+end
+
View
10 lib/authlogic_facebook_koala/session/base.rb
@@ -1,10 +0,0 @@
-module Authlogic
- module Session
- class Base
- extend AuthlogicFacebookKoala::Session::Config
- include AuthlogicFacebookKoala::Session::Adapter
- include AuthlogicFacebookKoala::Session::Facebook
- end
- end
-end
-
Please sign in to comment.
Something went wrong with that request. Please try again.