Module: Katello::UrlConstrainedCookieStoreV30X

Included in:
UrlConstrainedCookieStore
Defined in:
lib/katello/url_constrained_cookie_store.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

This is almost entirely based on ActionDispatch::Session::AbstractStore#call. Unfortunately, there isn’t a good way not to duplicate all this logic.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/katello/url_constrained_cookie_store.rb', line 4

def call(env)
  prepare!(env)
  response = @app.call(env)

  session_data = env[ActionDispatch::Session::AbstractStore::ENV_SESSION_KEY]
  options = env[ActionDispatch::Session::AbstractStore::ENV_SESSION_OPTIONS_KEY]

  if !session_data.is_a?(ActionDispatch::Session::AbstractStore::SessionHash) || session_data.loaded? || options[:expire_after]
    session_data.send(:load!) if session_data.is_a?(ActionDispatch::Session::AbstractStore::SessionHash) && !session_data.loaded?

    sid = options[:id] || generate_sid
    session_data = session_data.to_hash

    value = set_session(env, sid, session_data)
    return response unless value

    request = ActionDispatch::Request.new(env)
    cookie = create_cookie(request, value, options)
    set_cookie(request, cookie.merge!(options))
  end

  response
end