Class: Katello::UrlConstrainedCookieStore

Inherits:
ActionDispatch::Session::CookieStore
  • Object
show all
Includes:
UrlConstrainedCookieStoreV30X, UrlConstrainedCookieStoreV32X
Defined in:
lib/katello/url_constrained_cookie_store.rb

Instance Method Summary collapse

Methods included from UrlConstrainedCookieStoreV32X

#commit_session

Methods included from UrlConstrainedCookieStoreV30X

#call

Instance Method Details



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/katello/url_constrained_cookie_store.rb', line 69

def create_cookie(request, cookie_data, options)
  cookie = {}
  cookie[:value] = cookie_data
  if options[:expire_after]
    cookie[:value]['created_at'] ||= Time.now
    if expiration_exceptions(options).any? { |e| request.fullpath.include?(e) }
      cookie[:expires] = cookie[:value]['created_at'] + options[:expire_after]
    else
      cookie[:value]['created_at'] = Time.now
      cookie[:expires] = cookie[:value]['created_at'] + options[:expire_after]
    end
  end

  cookie
end

#expiration_exceptions(options) ⇒ Object



64
65
66
67
# File 'lib/katello/url_constrained_cookie_store.rb', line 64

def expiration_exceptions(options)
  exceptions = options[:expiration_exceptions] || []
  exceptions.instance_of?(Array) ? exceptions : [exceptions]
end