Sha256: c6d566d6550ce29a07a2517d86de2043ba9a95e28435a025b10191481cb8f140

Contents?: true

Size: 1.45 KB

Versions: 35

Compression:

Stored size: 1.45 KB

Contents

# Authlogic bridge for Sinatra
module Authlogic
  module ControllerAdapters
    module SinatraAdapter
      class Cookies
        attr_reader :request, :response

        def initialize(request, response)
          @request = request
          @response = response
        end

        def delete(key, options = {})
          @request.cookies.delete(key)
        end

        def []=(key, options)
          @response.set_cookie(key, options)
        end

        def method_missing(meth, *args, &block)
          @request.cookies.send(meth, *args, &block)
        end
      end

      class Controller
        attr_reader :request, :response, :cookies

        def initialize(request, response)
          @request = request
          @cookies = Cookies.new(request, response)
        end

        def session
          env['rack.session']
        end

        def method_missing(meth, *args, &block)
          @request.send meth, *args, &block
        end
      end

      class Adapter < AbstractAdapter
        def cookie_domain
          env['SERVER_NAME']
        end

        module Implementation
          def self.included(klass)
            klass.send :before do
              controller = Controller.new(request, response)
              Authlogic::Session::Base.controller = Adapter.new(controller)
            end
          end
        end
      end
    end
  end
end

Sinatra::Request.send(:include, Authlogic::ControllerAdapters::SinatraAdapter::Adapter::Implementation)

Version data entries

35 entries across 35 versions & 15 rubygems

Version Path
jlecour-authlogic-2.1.2 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-2.1.8 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-2.1.7 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-3.1.0 lib/authlogic/controller_adapters/sinatra_adapter.rb
Empact-authlogic-3.0.3 lib/authlogic/controller_adapters/sinatra_adapter.rb
expertiza-authlogic-2.1.6.1 lib/authlogic/controller_adapters/sinatra_adapter.rb
antlypls-authlogic-3.0.3 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-3.0.3 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-3.0.2 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-3.0.1 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-3.0.0 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-rails3-2.2 lib/authlogic/controller_adapters/sinatra_adapter.rb
kb-authlogic-2.1.7 lib/authlogic/controller_adapters/sinatra_adapter.rb
wulffeld_authlogic-2.1.3 lib/authlogic/controller_adapters/sinatra_adapter.rb
railsware-authlogic-2.1.6.1 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-2.1.6 lib/authlogic/controller_adapters/sinatra_adapter.rb
lockbox_middleware-1.2.1 vendor/gems/authlogic-2.1.3/lib/authlogic/controller_adapters/sinatra_adapter.rb
Empact-authlogic-2.1.5 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-2.1.5 lib/authlogic/controller_adapters/sinatra_adapter.rb
authlogic-2.1.4 lib/authlogic/controller_adapters/sinatra_adapter.rb