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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ae997f0e94f9476f63093f8eff2c6e7d007bb31
4
- data.tar.gz: 10d1131d46e13d193e339b56ff5e22a530bfed74
3
+ metadata.gz: e5608cb490be24dc64cd386667bfba91d31b2627
4
+ data.tar.gz: 020ffe74bdafa7d732066739a23e7cc0e58d3ec0
5
5
  SHA512:
6
- metadata.gz: da95de63a40ba868ff052b1e80ac12d199685aa2ea718ef88af9b015bcabae4475719d71d6db759d3e723a3043707196e63d1d2a32145ebefec9a14a9195746e
7
- data.tar.gz: af0cb327a3e0bc83a271633acdb6025046a42c885af2311468c0c72a1f58ff843a905685ade419e98bd5ad1b8c5d842cdeb6f33f2dcc5f0b15ddc0f6cb8949fd
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 logged_in? -%>
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
- map.active '/active', :controller => 'sessions', :action => 'active'
72
- map.timeout '/timeout', :controller => 'sessions', :action => 'timeout'
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 logged_in? -%>
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
@@ -1,7 +1,7 @@
1
1
  module Auto
2
2
  module Session
3
3
  module Timeout
4
- VERSION = "0.8"
4
+ VERSION = "0.9"
5
5
  end
6
6
  end
7
7
  end
@@ -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.send(:active_url) == c.url_for(c.params)
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 => logged_in?, :status => 200
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
- new Ajax.PeriodicalUpdater('', '/active', {frequency:#{frequency}, method:'get', onSuccess: function(e) {
6
- if (e.responseText == 'false') window.location.href = '/timeout';
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.8'
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-17 00:00:00.000000000 Z
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler