lib/omniauth/strategies/facebook.rb in oa-oauth-0.2.0.beta5 vs lib/omniauth/strategies/facebook.rb in oa-oauth-0.2.0
- old
+ new
@@ -24,10 +24,27 @@
def request_phase
options[:scope] ||= "email,offline_access"
super
end
+ def build_access_token
+ if facebook_session.nil? || facebook_session.empty?
+ super
+ else
+ @access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'])
+ end
+ end
+
+ def facebook_session
+ session_cookie = request.cookies["fbs_#{client.id}"]
+ if session_cookie
+ @facebook_session ||= Rack::Utils.parse_query(request.cookies["fbs_#{client.id}"].gsub('"', ''))
+ else
+ nil
+ end
+ end
+
def user_info
{
'nickname' => user_data["link"].split('/').last,
'email' => (user_data["email"] if user_data["email"]),
'first_name' => user_data["first_name"],
@@ -48,6 +65,6 @@
'extra' => {'user_hash' => user_data}
})
end
end
end
-end
\ No newline at end of file
+end