auto-session-timeout 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -6
- data/lib/auto/session/timeout/version.rb +1 -1
- data/lib/auto_session_timeout.rb +2 -2
- data/lib/auto_session_timeout_helper.rb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5608cb490be24dc64cd386667bfba91d31b2627
|
4
|
+
data.tar.gz: 020ffe74bdafa7d732066739a23e7cc0e58d3ec0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91e277d948c4364d670f9db9e549fa8770d243bc8cff3ea61dc05f3ba3df378c78d135ab93098dcc7944babdca135abc896e928de847fb5b379ae2c2bc91ad77
|
7
|
+
data.tar.gz: e99b135561c915cbbac6a19b5d4aa651e2508cda2e4cc3bc6516fea874d361eb1b8d281f339d1095a650908dd71bd6401749b3bdf9fd3989c99ad36ed035b39c
|
data/README.md
CHANGED
@@ -36,9 +36,9 @@ it if the user is logged in, otherwise the plugin will attempt to force
|
|
36
36
|
non-existent sessions to timeout, wreaking havoc:
|
37
37
|
|
38
38
|
<body>
|
39
|
-
<% if
|
39
|
+
<% if current_user %>
|
40
40
|
<%= auto_session_timeout_js %>
|
41
|
-
<% end
|
41
|
+
<% end %>
|
42
42
|
</body>
|
43
43
|
|
44
44
|
You need to setup two actions: one to return the session status and
|
@@ -68,8 +68,8 @@ actions entirely with your own custom code:
|
|
68
68
|
In any of these cases, make sure to properly map the actions in
|
69
69
|
your routes.rb file:
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
match 'active' => 'sessions#active', via: :get
|
72
|
+
match 'timeout' => 'sessions#timeout', via: :get
|
73
73
|
|
74
74
|
You're done! Enjoy watching your sessions automatically timeout.
|
75
75
|
|
@@ -83,13 +83,18 @@ seconds. The following example checks the server every 15 seconds:
|
|
83
83
|
<html>
|
84
84
|
<head>...</head>
|
85
85
|
<body>
|
86
|
-
<% if
|
86
|
+
<% if current_user %>
|
87
87
|
<%= auto_session_timeout_js :frequency => 15 %>
|
88
|
-
<% end
|
88
|
+
<% end %>
|
89
89
|
...
|
90
90
|
</body>
|
91
91
|
</html>
|
92
92
|
|
93
|
+
## TODO
|
94
|
+
|
95
|
+
* current_user must be defined
|
96
|
+
* using Prototype vs. jQuery
|
97
|
+
|
93
98
|
## Contributing
|
94
99
|
|
95
100
|
1. Fork it
|
data/lib/auto_session_timeout.rb
CHANGED
@@ -11,7 +11,7 @@ module AutoSessionTimeout
|
|
11
11
|
if c.session[:auto_session_expires_at] && c.session[:auto_session_expires_at] < Time.now
|
12
12
|
c.send :reset_session
|
13
13
|
else
|
14
|
-
unless c.
|
14
|
+
unless c.url_for(c.params).start_with?(c.send(:active_url))
|
15
15
|
c.session[:auto_session_expires_at] = Time.now + seconds
|
16
16
|
end
|
17
17
|
end
|
@@ -26,7 +26,7 @@ module AutoSessionTimeout
|
|
26
26
|
|
27
27
|
def render_session_status
|
28
28
|
response.headers["Etag"] = "" # clear etags to prevent caching
|
29
|
-
render :text =>
|
29
|
+
render :text => !!current_user, :status => 200
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_session_timeout
|
@@ -2,9 +2,16 @@ module AutoSessionTimeoutHelper
|
|
2
2
|
def auto_session_timeout_js(options={})
|
3
3
|
frequency = options[:frequency] || 60
|
4
4
|
code = <<JS
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
if (typeof(Ajax) != 'undefined') {
|
6
|
+
new Ajax.PeriodicalUpdater('', '/active', {frequency:#{frequency}, method:'get', onSuccess: function(e) {
|
7
|
+
if (e.responseText == 'false') window.location.href = '/timeout';
|
8
|
+
}});
|
9
|
+
} else {
|
10
|
+
$.PeriodicalUpdater('/active', {minTimeout:#{frequency * 1000}, multiplier:0, method:'get', verbose:2}, function(remoteData, success) {
|
11
|
+
if (success == 'success' && remoteData == 'false')
|
12
|
+
window.location.href = '/timeout';
|
13
|
+
});
|
14
|
+
}
|
8
15
|
JS
|
9
16
|
javascript_tag(code)
|
10
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto-session-timeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Bass
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|