docbrown/config/initializers/devise_monkeypatch.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

24 lines
1,001 B
Ruby

# Changing the value for "domain" in each context instead of using the one set on boot.
# This allows changing domain settings without restarting app.
module Devise
module Controllers
module Rememberable
# We need to use Settings::General.app_domain instead of default Rails config on boot
def remember_cookie_values(resource)
options = { httponly: true }
options.merge!(forget_cookie_values(resource))
options.merge!(
value: resource.class.serialize_into_cookie(resource),
expires: resource.remember_expires_at,
domain: ".#{Settings::General.app_domain}",
)
end
def self.cookie_values
# Default: Rails.configuration.session_options.slice(:path, :domain, :secure)
# We need to use Settings::General.app_domain instead of default Rails config on boot
{ domain: ".#{Settings::General.app_domain}", secure: ApplicationConfig["FORCE_SSL_IN_RAILS"] == "true" }
end
end
end
end