Sha256: 378f859f2c16b5e3a39a189bb6aec2e7278724e9b2dc29762e51d5465bd30a28

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

require 'warden'
require 'rails/session_cookie/app'

module Rails
  module SessionCookie
    # This mini rack app helps setting warden session cookie
    class WardenApp < App
      def initialize(user, session_options = nil, scope = :user)
        auth_session_options = session_options || rails_app.config.session_options
        serializer = Warden::SessionSerializer.new({})

        key = serializer.key_for(scope)
        value = serializer.store(user, scope)

        auth_app = proc { |env|
          env[Rails::SessionCookie::RACK_SESSION][key] = value
          [200, {}, []]
        }

        @app = with_middlewares(auth_app, auth_session_options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-session_cookie-0.2.0 lib/rails/session_cookie/warden_app.rb