multi_session_store 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f9a157dc153e9317fb348a08a01622d54a32740e15d1f9a10e6f25df5b1ace5
4
- data.tar.gz: 5a39919ab430cb0289bb92543603bbc756904f87bf069a2f3297c7f58e4b1a1c
3
+ metadata.gz: f4300243252df6e9c90b1432e2063d202009467f7ddc9a598ce1fdbaf25e4ad1
4
+ data.tar.gz: 7e1c9b49d42ba1bae75d7ebf67e2a45faea75e7d5a195b35e0facfe296a7425d
5
5
  SHA512:
6
- metadata.gz: 4dee99b46ba13077f0f171c45df70adaf3765854d22c6485d22d1dadfe9ee33ef7f881d6280f6a85b2b9944f41b2a2cac346c1ef72ba4f728ba27d75b6065b48
7
- data.tar.gz: 3b79761ed22d9054036833089970b4664c1f597ede00480ef286257ee24d72548b0844108956fcae3e4506550ac0ad57ac574c9258efdca409daf68121056f45
6
+ metadata.gz: '069e1432d811f474a43d6309c1c7a6b719291eb4d2facb74b1f96212d89a519cd6d3e92b0814f5893028cf0b03b531b0634802e700a6a6f73d07323127801916'
7
+ data.tar.gz: 6e7164dc18adb76b6f1861b351904384bece8b9ecb35c2d77d2b38f8d979a598cf6428c602b7d2a5b8351e8d872cc98998df7c53d23275a53b578a40ec04e735
@@ -9,10 +9,11 @@ module ActionDispatch
9
9
  module Session
10
10
  class MultiSessionStore < AbstractStore
11
11
  DEFAULT_SESSION_EXPIRATION = 24 * 60 * 60
12
+ DEFAULT_PARAM_NAME = 'subsession_id'.freeze
12
13
 
13
14
  def initialize(app, options = {})
14
15
  options[:expire_after] ||= DEFAULT_SESSION_EXPIRATION
15
- options[:param_name] ||= 'subsession_id'
16
+ options[:param_name] ||= DEFAULT_PARAM_NAME
16
17
  options[:serializer] ||= JSON
17
18
  @redis = options[:redis]
18
19
  @param_name = options[:param_name]
@@ -9,12 +9,23 @@ module MultiSessionStore
9
9
 
10
10
  def call(env)
11
11
  request = Rack::Request.new(env)
12
- request.update_param 'subsession_id', new_subsession_id if subsession_id_is_needed?(request)
12
+ set_subsession_id_from_header(request)
13
+ generate_subsession_id_if_needed(request)
13
14
  @app.call(env)
14
15
  end
15
16
 
16
17
  private
17
18
 
19
+ SUBSESSION_ID_HEADER = 'HTTP_X_SUBSESSIONID'.freeze
20
+
21
+ def set_subsession_id_from_header(request)
22
+ request.update_param 'subsession_id', request.get_header(SUBSESSION_ID_HEADER) if request.has_header?(SUBSESSION_ID_HEADER)
23
+ end
24
+
25
+ def generate_subsession_id_if_needed(request)
26
+ request.update_param 'subsession_id', new_subsession_id if subsession_id_is_needed?(request)
27
+ end
28
+
18
29
  def new_subsession_id
19
30
  SecureRandom.hex
20
31
  end
@@ -1,3 +1,3 @@
1
1
  module MultiSessionStore
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_session_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emarsys Smart Insight developers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-22 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack