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 +4 -4
- data/lib/multi_session_store.rb +18 -0
- data/lib/multi_session_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbecec0ef6651dd87a25775f87f983ece0717a1b556b6b270b8b212b5bd682fb
|
4
|
+
data.tar.gz: 95b5f276d54087c317dd5aaa2dcb65086ac6223dfe40b040ec1bc4a211c86522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5496cb0cac3da29e7c4172515fbb242fd03af12e8406662098d4096f22d8fb4ceecb4261a5fb27e5db5a7a3ba0608bcadd2dda7901013a6197ee1cdbc787c95
|
7
|
+
data.tar.gz: 5a7d0d199d17ceb091314d9512b58e7f928ad9a029a8b13d7d983f832bcbd228e1e94e462b9b1e7cfa1b71b34e42a4bb1f02d9ceb8d17193bf23a01884cb2ffc
|
data/lib/multi_session_store.rb
CHANGED
@@ -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
|
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.
|
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-
|
11
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|