Sha256: 5fda255f7cc316b2a94c340bae2a2289fc093bb5199ea31d8886e50c7581cbfb

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module Authlogic
  module ControllerAdapters
    # Adapts authlogic to work with rails. The point is to close the gap between what authlogic expects and what the rails controller object
    # provides. Similar to how ActiveRecord has an adapter for MySQL, PostgreSQL, SQLite, etc.
    class RailsAdapter < AbstractAdapter
      def authenticate_with_http_basic(&block)
        yield [nil, nil]
      end
      
      def cookies
        controller.send(:cookies)
      end
      
      def cookie_domain
        @cookie_domain_key ||= (Rails::VERSION::MAJOR >= 2 && Rails::VERSION::MINOR >= 3) ? :domain : :session_domain
        controller.class.session_options[@cookie_domain_key]
      end
      
      def request_content_type
        request.format.to_s
      end
      
      # Lets Authlogic know about the controller object via a before filter, AKA "activates" authlogic.
      module RailsImplementation
        def self.included(klass) # :nodoc:
          klass.prepend_before_filter :activate_authlogic
        end

        private
          def activate_authlogic
            Authlogic::Session::Base.controller = RailsAdapter.new(self)
          end
      end
    end
  end
end

ActionController::Base.send(:include, Authlogic::ControllerAdapters::RailsAdapter::RailsImplementation)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authlogic-2.0.5 lib/authlogic/controller_adapters/rails_adapter.rb