Sha256: 204b6e1f2d5fedb6d9b7fe999b98ee1023f5751aa8cc5a25d4b5b3498728dac0

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 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(*args, &block)
        controller.authenticate_with_http_basic(*args, &block)
      end
      
      def cookies
        controller.send(:cookies)
      end
      
      def request
        controller.request
      end
      
      def session
        controller.session
      end
    end
    
    # = Rails Implementation
    # Lets Authlogic know about the controller object, AKA "activates" authlogic.
    module RailsImplementation
      def self.included(klass) # :nodoc:
        klass.prepend_before_filter :set_controller
      end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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