Module: ThumbleMonks::SsoWhat::BaseDomainCookie

Defined in:
lib/thumblemonks/base_domain_cookie.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



4
5
6
# File 'lib/thumblemonks/base_domain_cookie.rb', line 4

def self.included(klass)
  klass.alias_method_chain :set_cookie, :domain_override
end

Instance Method Details



8
9
10
11
12
13
14
15
16
# File 'lib/thumblemonks/base_domain_cookie.rb', line 8

def set_cookie_with_domain_override(key, value)
  value = {:value => value} unless value.is_a?(Hash)
  domain_requested, host = value[:domain], request.host
  unless domain_requested || host_has_no_tld?(host)
    domain_requested = host.gsub(/^(.*\.)?([a-z0-9-]+\.[a-z]+)$/i, '\2')
    value[:domain] = ".#{domain_requested}"
  end
  set_cookie_without_domain_override(key, value)
end