diff options
author | Siddharth Bhatore <sbhatore95@gmail.com> | 2015-04-23 22:56:56 +0530 |
---|---|---|
committer | Siddharth Bhatore <sbhatore95@gmail.com> | 2015-04-23 22:56:56 +0530 |
commit | f92f5b706b01a83e881a28ddef8ddd741144c6d4 (patch) | |
tree | af376602ff124a8430c01abed4f05ccfa470bb75 /actionpack/lib | |
parent | 4e141f16ecc9c442772e361cb526d9b381b1c93e (diff) | |
download | rails-f92f5b706b01a83e881a28ddef8ddd741144c6d4.tar.gz rails-f92f5b706b01a83e881a28ddef8ddd741144c6d4.tar.bz2 rails-f92f5b706b01a83e881a28ddef8ddd741144c6d4.zip |
Squashed commit of the following:
commit a88875ac6abaa4d8116b42af8cd71189ce3d44d3
Author: Siddharth Bhatore <sbhatore95@gmail.com>
Date: Thu Apr 23 12:26:08 2015 +0530
[ci skip] Update doc fix cookies
commit f175eaa7a21db898fc6c66334f770831028f9d00
Author: Siddharth Bhatore <sbhatore95@gmail.com>
Date: Mon Apr 20 12:58:04 2015 +0530
Description inside Signed and Encrypted CookieJars added
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/cookies.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb index b7687ca100..0ef1dd3ae5 100644 --- a/actionpack/lib/action_dispatch/middleware/cookies.rb +++ b/actionpack/lib/action_dispatch/middleware/cookies.rb @@ -454,12 +454,16 @@ module ActionDispatch @verifier = ActiveSupport::MessageVerifier.new(secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer) end + # Returns the value of the cookie by +name+ if it is untampered, + # returns +nil+ otherwise or if no such cookie exists. def [](name) if signed_message = @parent_jar[name] deserialize name, verify(signed_message) end end + # Signs and Sets the cookie named +name+. The second argument may be the cookie's + # value or a hash of options as documented above. def []=(name, options) if options.is_a?(Hash) options.symbolize_keys! @@ -511,12 +515,16 @@ module ActionDispatch @encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, digest: digest, serializer: ActiveSupport::MessageEncryptor::NullSerializer) end + # Returns the value of the cookie by +name+ if it is untampered, + # returns +nil+ otherwise or if no such cookie exists. def [](name) if encrypted_message = @parent_jar[name] deserialize name, decrypt_and_verify(encrypted_message) end end + # Encrypts and Sets the cookie named +name+. The second argument may be the cookie's + # value or a hash of options as documented above. def []=(name, options) if options.is_a?(Hash) options.symbolize_keys! |