Sha256: ff718d3274dd8612a7aec1faf51142a92ddaab93d527cd7938c411026b672e40

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

module Authlogic
  module ControllerAdapters # :nodoc:
    # Allows you to use Authlogic in any framework you want, not just rails. See the RailsAdapter or MerbAdapter
    # for an example of how to adapt Authlogic to work with your framework.
    class AbstractAdapter
      attr_accessor :controller

      def initialize(controller)
        self.controller = controller
      end
      
      def authenticate_with_http_basic(&block)
        @auth = Rack::Auth::Basic::Request.new(controller.request.env)
        if @auth.provided? and @auth.basic?
          block.call(*@auth.credentials)
        else
          false
        end
      end
      
      def cookies
        controller.cookies
      end
      
      def cookie_domain
        raise NotImplementedError.new("The cookie_domain method has not been implemented by the controller adapter")
      end

      def params
        controller.params
      end

      def request
        controller.request
      end

      def request_content_type
        request.content_type
      end

      def session
        controller.session
      end
      
      def single_access_allowed?
        controller.respond_to?(:single_access_allowed?, true) && controller.send(:single_access_allowed?)
      end
      
      private
        def method_missing(id, *args, &block)
          controller.send(id, *args, &block)
        end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
authlogic-2.0.0 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.1 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.3 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.4 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.6 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.7 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.8 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.2 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.5 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-2.0.9 lib/authlogic/controller_adapters/abstract_adapter.rb