diff --git a/app/controllers/stormpath/rails/base_controller.rb b/app/controllers/stormpath/rails/base_controller.rb index ee6061c..9b22d93 100644 --- a/app/controllers/stormpath/rails/base_controller.rb +++ b/app/controllers/stormpath/rails/base_controller.rb @@ -4,10 +4,14 @@ class BaseController < ApplicationController include Stormpath::Rails::Controller before_action :setup_accept_header - skip_before_action :verify_authenticity_token, if: :api_request? - skip_before_action :verify_authenticity_token, if: :in_development? + if respond_to?(:verify_authenticity_token) + skip_before_action :verify_authenticity_token, if: :api_request? + skip_before_action :verify_authenticity_token, if: :in_development? + end - layout 'stormpath/rails/layouts/stormpath' + if respond_to?(:layout) + layout 'stormpath/rails/layouts/stormpath' + end private @@ -54,14 +58,18 @@ def current_organization_name_key nil end end - helper_method :current_organization_name_key + if respond_to?(:helper_method) + helper_method :current_organization_name_key + end def social_auth @social_auth ||= SocialLoginUrlBuilder.call( req.base_url, organization_name_key: current_organization_name_key ) end - helper_method :social_auth + if respond_to?(:helper_method) + helper_method :social_auth + end def req request diff --git a/lib/stormpath/rails/controller.rb b/lib/stormpath/rails/controller.rb index 2a14177..a185f96 100644 --- a/lib/stormpath/rails/controller.rb +++ b/lib/stormpath/rails/controller.rb @@ -14,6 +14,13 @@ module Controller def current_account @current_account ||= begin + cookies = + if respond_to?(:cookies) + cookies + else + {} + end + ControllerAuthentication.new(cookies, request.headers['Authorization']).authenticate! rescue ControllerAuthentication::UnauthenticatedRequest, Stormpath::Error, JWT::DecodeError nil diff --git a/lib/stormpath/rails/social.rb b/lib/stormpath/rails/social.rb index bba9c1a..7a8d3ed 100644 --- a/lib/stormpath/rails/social.rb +++ b/lib/stormpath/rails/social.rb @@ -4,7 +4,9 @@ module Social extend ActiveSupport::Concern included do - helper_method :social_providers_present? + if respond_to?(:helper_method) + helper_method :social_providers_present? + end end private