Sha256: 305e6765ecc3367b7ada0129c5b4e168cb530a44dab003638afa5e07c47f2720
Contents?: true
Size: 1.09 KB
Versions: 8
Compression:
Stored size: 1.09 KB
Contents
class Galakei::SessionIdParameter::InUrl < Galakei::Filter::Base def filter key = ::Rails.application.config.session_options[:key] if device_needs_session_param_in_url? session_opts = env[ActionDispatch::Session::AbstractStore::ENV_SESSION_OPTIONS_KEY] # if we don't have a session ID yet, create one if session_opts[:id].blank? # make sure to reset any active record session store, # we'll have to create a new one for the new session env[ActiveRecord::SessionStore::SESSION_RECORD_KEY] = nil # create a new session ID session_opts[:id] = ActiveSupport::SecureRandom.hex(8) end sid = session_opts[:id] logger.debug("Galakei: adding session param '#{key}' to default_url_options") default_url_options[key] = sid else # default_url_options aren't cleared, so we need to clear them default_url_options.delete(key) end end private def device_needs_session_param_in_url? galakei? && !request.cookies? && session end def default_url_options controller.send :default_url_options end end
Version data entries
8 entries across 8 versions & 1 rubygems