Created
September 28, 2010 03:09
-
-
Save mnelson/600328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FacebookSession | |
module Session | |
def self.included(base) | |
base.class_eval do | |
cattr_accessor :finding_current | |
include Methods | |
end | |
end | |
module Methods | |
def validate_by_facebook_connect | |
return if self.class.finding_current | |
self.class.finding_current = true | |
alt_session = self.class.find | |
self.class.finding_current = false | |
alt_record = alt_session && alt_session.record || nil | |
if alt_record | |
facebook_session = controller.facebook_session | |
alt_record.send("#{facebook_uid_field}=", facebook_session.user.uid) | |
alt_record.send("#{facebook_session_key_field}=", facebook_session.session_key) | |
alt_record.before_connect(facebook_session) if alt_record.respond_to?(:before_connect) | |
alt_record.save | |
self.attempted_record = alt_record | |
else | |
super | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'facebook_session' | |
class UserSession < Authlogic::Session::Base | |
include FacebookSession::Session | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment