Sha256: e1bdd98eb587d9ab135df17fb883409b86e7995fa49f73825ae8d989fa106076

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

module Authlogic
  module ControllerAdapters # :nodoc:
    # = Abstract Adapter
    #
    # Allows you to use Authlogic in any framework you want, not just rails. See tha RailsAdapter for an example of how to adapter 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 params
        controller.params
      end

      def request
        controller.request
      end

      def request_content_type
        request.content_type
      end

      def session
        controller.session
      end
      
      private
        def method_missing(id, *args, &block)
          controller.send(id, *args, &block)
        end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
authlogic-1.3.0 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.1 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.2 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.3 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.4 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.5 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.6 lib/authlogic/controller_adapters/abstract_adapter.rb
authlogic-1.3.7 lib/authlogic/controller_adapters/abstract_adapter.rb