auto-session-timeout-warning 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Auto
2
2
  module Session
3
3
  module Timeout
4
4
  module Warning
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
8
8
  end
@@ -27,7 +27,7 @@ module AutoSessionTimeoutWarning
27
27
 
28
28
  def render_session_status
29
29
  response.headers["Etag"] = "" # clear etags to prevent caching
30
- render text: !!current_user, status: 200
30
+ render json: {live: !!current_user, timeout: session[:auto_session_expires_at]}
31
31
  end
32
32
 
33
33
  def render_session_timeout
@@ -32,9 +32,11 @@ if(typeof(jQuery) != 'undefined'){
32
32
  $.ajax({
33
33
  url: '/active',
34
34
  success: function(data) {
35
- if(data == 'false'){
35
+ if(new Date(data.timeout).getTime() < (new Date().getTime() + #{warning} * 1000)){
36
36
  showDialog();
37
- setTimeout(doTimeout, (#{warning} * 1000));
37
+ }
38
+ if(data.live == false){
39
+ window.location.href = '/timeout';
38
40
  }
39
41
  }
40
42
  });
@@ -45,10 +47,6 @@ if(typeof(jQuery) != 'undefined'){
45
47
  function showDialog(){
46
48
  $('.logout_dialog').trigger('click');
47
49
  }
48
-
49
- function doTimeout(){
50
- window.location.href = '/timeout';
51
- }
52
50
  }
53
51
  JS
54
52
  javascript_tag(code)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto-session-timeout-warning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler