rack-redis-session-store 2.0.2 → 2.0.3

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
  SHA1:
3
- metadata.gz: c8b02f85c45a99fc7975c7fef85be45039b7ce91
4
- data.tar.gz: f99015530378207faee2f48b122a18d177508f90
3
+ metadata.gz: a6b92694592164facffa121a611d0dc3d91ec136
4
+ data.tar.gz: 4f26f80bba4017629352c698d6c2b5099993e434
5
5
  SHA512:
6
- metadata.gz: 15d6522a10cbf5d6f0f4c6e389674a300c772dbd867b345cd4a678ee22b54074bb464af4480c318529d23ca3339e8f2fd0bedd6f6f7d2a326a9c725122289f63
7
- data.tar.gz: 8857f03b7b076e04e19d04e52a0e053d3765a65f726b93dd2ce3436e6c29c8ec7389d5cf5075fb8aec436c46f0bad7cb9c508d1ea513b08a01ba55a0276dd64a
6
+ metadata.gz: 1156d282e92feb912eb5a2e549bb2dbbb1dfb1a7e4bfceb18e50f6532831ef0b5ebc54e3e02f0840fbe8ee361c47d911499584db41962ae2a649d5c39bcadaf1
7
+ data.tar.gz: b88e3ec0c62d51653c700d422b332f89e22d0ed9ad1d9358a955ebe445e8291801becde4f0d918b2c1964d40ac1df90997769434bdeb2e57ecb8b6d5ec893e4c
@@ -24,41 +24,32 @@ module ActionDispatch
24
24
  end
25
25
 
26
26
  def get_session(env, sid)
27
- session = {}
28
- if sid!='null'
29
- @redis.with do |redis|
30
- options = env['rack.session.options']
31
- session_string = redis.get(sid)
32
- if session_string
33
- session = JSON.parse(session_string)
34
- end
27
+ @redis.with do |redis|
28
+ unless sid and session = JSON.parse(redis.get(sid))
29
+ sid, session = generate_sid, {}
35
30
  end
36
- else
37
- sid = generate_sid
31
+ [sid, session]
38
32
  end
39
- [sid, session]
40
33
  end
41
34
 
42
35
  def set_session(env, session_id, new_session, options)
43
- if (!new_session.empty?)
44
- @redis.with do |redis|
45
- json = Jbuilder.encode do |json|
46
- json.(new_session, *new_session.keys)
47
- end
48
- redis.setex session_id, options[:expire_after],json
36
+ expiry = options[:expire_after]
37
+ expiry = expiry.nil? ? 0 : expiry + 1
38
+
39
+ @redis.with do |redis|
40
+ json = Jbuilder.encode do |json|
41
+ json.(new_session, *new_session.keys)
49
42
  end
43
+ redis.setex session_id, expiry,json
44
+ session_id
50
45
  end
51
- #For some reason, rack doesn't set new session_id to options[:id]
52
- options[:id] = session_id
53
- return session_id
54
46
  end
55
47
 
56
48
  def destroy_session(env, session_id, options)
57
- puts('Destroy session')
58
49
  @redis.with do |redis|
59
50
  redis.del(session_id)
51
+ generate_sid unless options[:drop]
60
52
  end
61
- generate_sid unless options[:drop]
62
53
  end
63
54
  end
64
55
  end
data/lib/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION = '2.0.2'
1
+ VERSION = '2.0.3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-redis-session-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Le Duc Duy