Sha256: 5f511c47d6f71179bea4cd9a622324cfa044e0cf015b246bb42e1f626cc1cd31

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Authlogic
  module ControllerAdapters
    # = Rails Adapter
    # 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)
        __getobj__.authenticate_with_http_basic(&block)
      end
      
      def cookies
        __getobj__.send(:cookies)
      end
      
      def request_content_type
        request.format.to_s
      end
      
      # = Rails Implementation
      # Lets Authlogic know about the controller object, 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-1.2.2 lib/authlogic/controller_adapters/rails_adapter.rb