auto-session-timeout 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/lib/auto/session/timeout/version.rb +1 -1
- data/lib/auto_session_timeout.rb +2 -2
- data/test/auto_session_timeout_helper_test.rb +35 -0
- data/test/test_helper.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzgzYWM4ODdjNTcwYWI5MmMxZDA0ZDc3NjBjYzRlNmJiN2Q4ZDk3OQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTU4MzEyZDc4OTE4YmVmZWM2NmUwY2EwYTI2YjcxZjU1NzRiZDM4NA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmFiZGY1NjI4M2M2ZTUzNTZlNmM3OTY5ZjBjM2QyNjA2ZDZkZjE0ODIyYzg1
|
10
|
+
MDhhZjQ1MmE4Y2RmMTYxNzQwMDMxZWI1NzhjYmYzMmZiNTYyZjI0M2NiNWFi
|
11
|
+
MDdjZmUzMTlmOTliODc3OTAxNTExOTdjYTExOTY0ODk2ZTcyYTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGZkMjVmNjA5ZjU0YjYxMmJhMjZhYTI3ZTU4YjZlYzRhZjQ5YTNlODkzNmY4
|
14
|
+
NjQyZmM4YzI5Mjk3MmIxOGMxYWU1NmI1NDc3OWFiZjJmZWMwNGI4ZjA4NDI0
|
15
|
+
NDZlNGJjZDQ5NmFjNThmM2RkZDg5ZmU5NzBkOGVmZGRhNmMyYzg=
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/auto_session_timeout.rb
CHANGED
@@ -12,7 +12,7 @@ module AutoSessionTimeout
|
|
12
12
|
c.send :reset_session
|
13
13
|
else
|
14
14
|
unless c.url_for(c.params).start_with?(c.send(:active_url))
|
15
|
-
offset = seconds || current_user.
|
15
|
+
offset = seconds || (current_user.respond_to?(:auto_timeout) ? current_user.auto_timeout : nil)
|
16
16
|
c.session[:auto_session_expires_at] = Time.now + offset if offset && offset > 0
|
17
17
|
end
|
18
18
|
end
|
@@ -27,7 +27,7 @@ module AutoSessionTimeout
|
|
27
27
|
|
28
28
|
def render_session_status
|
29
29
|
response.headers["Etag"] = "" # clear etags to prevent caching
|
30
|
-
render :
|
30
|
+
render text: !!current_user, status: 200
|
31
31
|
end
|
32
32
|
|
33
33
|
def render_session_timeout
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
describe AutoSessionTimeoutHelper do
|
4
|
+
|
5
|
+
subject { Class.new(ActionView::Base).new }
|
6
|
+
|
7
|
+
describe "#auto_session_timeout_js" do
|
8
|
+
it "returns correct JS" do
|
9
|
+
assert_equal "<script type=\"text/javascript\">
|
10
|
+
//<![CDATA[
|
11
|
+
if (typeof(Ajax) != 'undefined') {
|
12
|
+
new Ajax.PeriodicalUpdater('', '/active', {frequency:60, method:'get', onSuccess: function(e) {
|
13
|
+
if (e.responseText == 'false') window.location.href = '/timeout';
|
14
|
+
}});
|
15
|
+
} else {
|
16
|
+
$.PeriodicalUpdater('/active', {minTimeout:60000, multiplier:0, method:'get', verbose:2}, function(remoteData, success) {
|
17
|
+
if (success == 'success' && remoteData == 'false')
|
18
|
+
window.location.href = '/timeout';
|
19
|
+
});
|
20
|
+
}
|
21
|
+
|
22
|
+
//]]>
|
23
|
+
</script>", subject.auto_session_timeout_js
|
24
|
+
end
|
25
|
+
|
26
|
+
it "uses custom frequency when given" do
|
27
|
+
assert_match /frequency:120/, subject.auto_session_timeout_js(frequency: 120)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "uses 60 when custom frequency is nil" do
|
31
|
+
assert_match /frequency:60/, subject.auto_session_timeout_js(frequency: nil)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto-session-timeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Bass
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/auto/session/timeout/version.rb
|
86
86
|
- lib/auto_session_timeout.rb
|
87
87
|
- lib/auto_session_timeout_helper.rb
|
88
|
+
- test/auto_session_timeout_helper_test.rb
|
88
89
|
- test/auto_session_timeout_test.rb
|
89
90
|
- test/test_helper.rb
|
90
91
|
homepage: http://github.com/pelargir/auto-session-timeout
|
@@ -112,5 +113,6 @@ signing_key:
|
|
112
113
|
specification_version: 4
|
113
114
|
summary: Provides automatic session timeout in a Rails application.
|
114
115
|
test_files:
|
116
|
+
- test/auto_session_timeout_helper_test.rb
|
115
117
|
- test/auto_session_timeout_test.rb
|
116
118
|
- test/test_helper.rb
|