diff options
author | Mark J. Titorenko <mark@titorenko.net> | 2013-01-08 10:06:14 +0000 |
---|---|---|
committer | Mark J. Titorenko <mark@titorenko.net> | 2013-01-08 10:10:36 +0000 |
commit | fc66b6b00472426b3e01ea8f394825af3c66b6ef (patch) | |
tree | 200b8c6d456a113e407def223bbd8b31bae4935d /actionpack/lib/action_dispatch/middleware/session | |
parent | 3e71f5759aace5aae16e2ad12108cdabc41944c4 (diff) | |
download | rails-fc66b6b00472426b3e01ea8f394825af3c66b6ef.tar.gz rails-fc66b6b00472426b3e01ea8f394825af3c66b6ef.tar.bz2 rails-fc66b6b00472426b3e01ea8f394825af3c66b6ef.zip |
Fix CookieStore middleware inheritance hierarchy s.t. it inherits from Rack::Session::Abstract::ID rather than Rack::Session::Cookie.
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware/session')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/session/cookie_store.rb | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb index 4437b50f1f..1e6ed624b0 100644 --- a/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/cookie_store.rb @@ -36,21 +36,38 @@ module ActionDispatch # "rake secret" and set the key in config/initializers/secret_token.rb. # # Note that changing digest or secret invalidates all existing sessions! - class CookieStore < Rack::Session::Cookie + class CookieStore < Rack::Session::Abstract::ID include Compatibility include StaleSessionCheck include SessionObject - # Override rack's method + def initialize(app, options={}) + super(app, options.merge!(:cookie_only => true)) + end + def destroy_session(env, session_id, options) - new_sid = super + new_sid = generate_sid unless options[:drop] # Reset hash and Assign the new session id env["action_dispatch.request.unsigned_session_cookie"] = new_sid ? { "session_id" => new_sid } : {} new_sid end + def load_session(env) + stale_session_check! do + data = unpacked_cookie_data(env) + data = persistent_session_id!(data) + [data["session_id"], data] + end + end + private + def extract_session_id(env) + stale_session_check! do + unpacked_cookie_data(env)["session_id"] + end + end + def unpacked_cookie_data(env) env["action_dispatch.request.unsigned_session_cookie"] ||= begin stale_session_check! do @@ -62,6 +79,12 @@ module ActionDispatch end end + def persistent_session_id!(data, sid=nil) + data ||= {} + data["session_id"] ||= sid || generate_sid + data + end + def set_session(env, sid, session_data, options) session_data["session_id"] = sid session_data |