multi_session_store 0.2.1 → 0.2.2

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: d5da82bc7386c040cd586cc36c42feb917b41e55886c38b7dcdedd33705d478c
4
- data.tar.gz: ea4d3ead909c521a46f2d61e1ad8a666508a65533652d70ce151e6c68a394cd8
3
+ metadata.gz: dbecec0ef6651dd87a25775f87f983ece0717a1b556b6b270b8b212b5bd682fb
4
+ data.tar.gz: 95b5f276d54087c317dd5aaa2dcb65086ac6223dfe40b040ec1bc4a211c86522
5
5
  SHA512:
6
- metadata.gz: a6fe4fd2eb79b0bdea61ac1e38b7956a46bf724b756bb2353d407c254f5a4376f97c6123287d1c95445c164547c471c25101e0ef92b5296e2d3307567855dd70
7
- data.tar.gz: 226b38cfecfbb54d383aa2b7ea1460bab6a069d98361a16eb54860da8420b43ae550d84b20bb2b925442f21d75ab6bd0f693c26b62feb38fdfcce9e009ea752b
6
+ metadata.gz: b5496cb0cac3da29e7c4172515fbb242fd03af12e8406662098d4096f22d8fb4ceecb4261a5fb27e5db5a7a3ba0608bcadd2dda7901013a6197ee1cdbc787c95
7
+ data.tar.gz: 5a7d0d199d17ceb091314d9512b58e7f928ad9a029a8b13d7d983f832bcbd228e1e94e462b9b1e7cfa1b71b34e42a4bb1f02d9ceb8d17193bf23a01884cb2ffc
@@ -3,6 +3,7 @@ require "multi_session_store/subsession_generator_middleware"
3
3
  require "multi_session_store/default_url_options"
4
4
  require "multi_session_store/railtie" if defined? Rails
5
5
  require "action_dispatch"
6
+ require 'json'
6
7
 
7
8
  module ActionDispatch
8
9
  module Session
@@ -12,6 +13,7 @@ module ActionDispatch
12
13
  def initialize(app, options = {})
13
14
  options[:expire_after] ||= DEFAULT_SESSION_EXPIRATION
14
15
  options[:param_name] ||= 'subsession_id'
16
+ options[:serializer] ||= JSON
15
17
  @redis = options[:redis]
16
18
  @param_name = options[:param_name]
17
19
  @serializer = options[:serializer]
@@ -43,12 +45,28 @@ module ActionDispatch
43
45
  sid
44
46
  end
45
47
 
48
+ def validate_sessions(&block)
49
+ all_sessions.each do |key, session|
50
+ @redis.del key unless block.call session
51
+ end
52
+ end
53
+
46
54
  private
47
55
 
48
56
  def session_store_key(env, sid)
49
57
  subsession_id = env.params[@param_name] || 'no_subsession'
50
58
  "_session_id:#{sid}:#{subsession_id}"
51
59
  end
60
+
61
+ def all_sessions
62
+ session_store_keys.each_with_object({}) do |key, memo|
63
+ memo[key] = @serializer.parse(@redis.get(key))
64
+ end
65
+ end
66
+
67
+ def session_store_keys
68
+ @redis.keys "_session_id:*"
69
+ end
52
70
  end
53
71
  end
54
72
  end
@@ -1,3 +1,3 @@
1
1
  module MultiSessionStore
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
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.1
4
+ version: 0.2.2
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-18 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack