Sha256: 1a8a4d0e331db23fbe0cd35a90cb68ea942b32e05aef1d6e479b9bbcbd90773e
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module IntercomRails module ShutdownHelper # This helper allows to erase cookies when a user log out of an application # It is recommanded to call this function every time a user log out of your application # Do not use before a redirect_to because it will not clear the cookies on a redirection def self.intercom_shutdown_helper(cookies) if (cookies.is_a?(ActionDispatch::Cookies::CookieJar)) cookies["intercom-session-#{IntercomRails.config.app_id}"] = { value: nil, expires: 1.day.ago} else controller = cookies Rails.logger.info("Warning: IntercomRails::ShutdownHelper.intercom_shutdown_helper takes an instance of ActionDispatch::Cookies::CookieJar as an argument since v0.2.34. Passing a controller is depreciated. See https://github.com/intercom/intercom-rails#shutdown for more details.") controller.response.delete_cookie("intercom-session-#{IntercomRails.config.app_id}", { value: nil, expires: 1.day.ago}) end rescue end def self.prepare_intercom_shutdown(session) session[:perform_intercom_shutdown] = true end def self.intercom_shutdown(session, cookies) if session[:perform_intercom_shutdown] session.delete(:perform_intercom_shutdown) intercom_shutdown_helper(cookies) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
intercom-rails-0.3.8 | lib/intercom-rails/shutdown_helper.rb |