Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added helper method fb_canvas?

  • Loading branch information...
commit 1f5a074b263394f01a4f04a407e471b2ca3fde4a 1 parent 4ceefc4
@ahmadeeva-su ahmadeeva-su authored
View
3  .gitignore
@@ -1,2 +1,3 @@
pkg
-*~
+*~
+.project
View
7 lib/facepalm/rails/controller.rb
@@ -16,7 +16,7 @@ def self.included(base)
# Fix cookie permission issue in IE
before_filter :normal_cookies_for_ie_in_iframes!
- helper_method(:facepalm, :fb_signed_request, :current_facebook_user, :params_without_facebook_data)
+ helper_method(:facepalm, :fb_signed_request, :current_facebook_user, :params_without_facebook_data, :fb_canvas?)
helper Facepalm::Rails::Helpers
end
@@ -50,6 +50,11 @@ def fb_signed_request
def params_without_facebook_data
params.except(:signed_request)
end
+
+ # Did the request come from canvas app
+ def fb_canvas?
+ request.env['HTTP_SIGNED_REQUEST'].present?
+ end
private
View
14 lib/facepalm/rails/controller/oauth_access.rb
@@ -74,16 +74,11 @@ def facepalm_require_authentication(*permissions)
if current_facebook_user.try(:authenticated?)
true
else
- # Encrypting return URL to pass it to Facebook
- return_code = facepalm_url_encryptor.encrypt(
- url_for(params_without_facebook_data.merge(:canvas => false, :only_path => true))
- )
-
redirect_from_iframe(
facepalm.oauth_client.url_for_oauth_code(
:permissions => permissions,
:callback => facepalm_endpoint_url(
- :fb_return_to => ::Rack::Utils.escape(return_code)
+ :fb_return_to => ::Rack::Utils.escape(facepalm_auth_return_code)
)
)
)
@@ -91,6 +86,13 @@ def facepalm_require_authentication(*permissions)
false
end
end
+
+ # Encrypting return URL to pass it to Facebook
+ def facepalm_auth_return_code
+ facepalm_url_encryptor.encrypt(
+ url_for(params_without_facebook_data.merge(:canvas => false, :only_path => true))
+ )
+ end
# Internally used to encrypt return URL for authentication endpoint
#
Please sign in to comment.
Something went wrong with that request. Please try again.