auto-session-timeout-warning 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb7bd14dcfcc3447b244d07ed4094c43d244c0a5
4
+ data.tar.gz: 385d483d861f8abb2154f871786b93a3035c919c
5
+ SHA512:
6
+ metadata.gz: 0058b81ab6d2d06d447125962ebd24017e8068239e025673eddf135958fae97c7cfdc162faa726022743689902fa35d84d7460aa35d214d3e1b6efb0c553b85c
7
+ data.tar.gz: 8b9cfb457e72163fac5a05b7e9bbbec6e8107195dd421e8efdb4ae02102575306e28c44a23f699a24bb93f9456bed296c17284184ef872418ad9a575575e048f
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # auto-session-timeout-warning
2
2
 
3
3
  This provides warning message before auto session timeout in Rails application,
4
- if you don't looking for warning message before session timeout please check source gem
4
+ if you don't looking for warning message before session timeout please find the auto session timeout gem here
5
+
5
6
  https://github.com/pelargir/auto-session-timeout
6
7
 
8
+ ---
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -17,15 +19,22 @@ And then execute:
17
19
  Or install it yourself as:
18
20
 
19
21
  $ gem install auto-session-timeout-warning
20
-
21
- ## Usage
22
+ ---
23
+ ## How to use?
24
+ ### Add jQuery and jQuery UI
22
25
  Add jquery and jquery-ui on your application.js file, set the current_user helper method in application controller if its not yet defined
23
26
 
24
- Add before_timedout_action in application controller
27
+ ### Setup
28
+ setup your application controller to use auto timeout warning. Here I setup the session timeout warning to 20 minutes of inactivity.
29
+ ```
30
+ class ApplicationController < ActionController::Base
31
+ auto_session_timeout 20.minutes
32
+ end
33
+ ```
25
34
 
35
+ Add before_timedout_action in application controller
26
36
  ```
27
37
  class ApplicationController < ActionController::Base
28
- #Add protected before_timedout action
29
38
  before_timedout_action
30
39
  end
31
40
  ```
@@ -43,33 +52,27 @@ class ApplicationController < ActionController::Base
43
52
  end
44
53
  ```
45
54
 
46
- and follow all steps as for https://github.com/pelargir/auto-session-timeout.
47
-
48
-
49
- Check below configuration for warning message
50
-
51
-
52
- ## Warning message Configuration
53
- <html>
54
- <head>...</head>
55
+ ### Warning message configuration
56
+ Add warning tag and auto session_timeout javascript config in views like application layout or any other page
57
+ ```
55
58
  <body>
56
59
  <% if current_user %>
60
+ <%= auto_session_warning_tag %>
57
61
  <%= auto_session_timeout_js timeout: 60, frequency: 60, start: 60, warning: 20 %>
58
62
  <% end %>
59
63
  ...
60
64
  </body>
61
- </html>
62
-
63
- frequency refers to how frequently browser interactive with server to find the session details,
64
-
65
- timeout refers to auto session time out, if you set auto_session_timeout: 2.minutes on application_controller, you should set 120 seconds here,
65
+ ```
66
+ #### auto_session_timeout_js config details here
67
+ **frequency:** how frequently browser interactive with server to find the session details,
66
68
 
67
- start describes the starting time of server interaction, if it is 60, first server interaction will start after 60 seconds,
69
+ **timeout:** auto session time out in seconds. If you set auto_session_timeout: 2.minutes on application_controller, you should set 120 seconds here.
68
70
 
69
- warning describes the starting time of warning message before session timed out, if is 20, dialog warning message will popup before 20 seconds of timeout.
71
+ **start:** starting time of server interaction. If it is 60, first server interaction will start after 60 seconds,
70
72
 
71
- Default values here:
73
+ **warning:** Show warning message before session timed out. If it is 20, dialog warning message will popup before 20 seconds of timeout.
72
74
 
75
+ *Default values here:*
73
76
  timeout: 60,
74
77
  frequecy: 60,
75
78
  start: 60,
@@ -2,7 +2,7 @@ module Auto
2
2
  module Session
3
3
  module Timeout
4
4
  module Warning
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
8
8
  end
@@ -12,7 +12,7 @@ module AutoSessionTimeoutWarning
12
12
  c.send :before_timedout
13
13
  c.send :reset_session
14
14
  else
15
- unless c.url_for(c.params).start_with?(c.send(:active_url))
15
+ unless c.request.original_url.start_with?(c.send(:active_url))
16
16
  offset = seconds || (current_user.respond_to?(:auto_timeout) ? current_user.auto_timeout : nil)
17
17
  c.session[:auto_session_expires_at] = Time.now + offset if offset && offset > 0
18
18
  end
@@ -43,4 +43,4 @@ module AutoSessionTimeoutWarning
43
43
 
44
44
  end
45
45
 
46
- ActionController::Base.send :include, AutoSessionTimeoutWarning
46
+ ActionController::Base.send :include, AutoSessionTimeoutWarning
@@ -8,7 +8,6 @@ module AutoSessionTimeoutWarningHelper
8
8
  if(typeof(jQuery) != 'undefined'){
9
9
  $("#logout_dialog").dialog({
10
10
  modal: true,
11
- bgiframe: true,
12
11
  width: 500,
13
12
  height: 180,
14
13
  autoOpen: false,
@@ -18,11 +17,19 @@ if(typeof(jQuery) != 'undefined'){
18
17
  $(".logout_dialog").click(function (e) {
19
18
  e.preventDefault();
20
19
 
21
- $("#logout_dialog").dialog('option', 'buttons', {
22
- "Continue": function () {
23
- window.location.reload();
24
- }
25
- });
20
+ $("#logout_dialog").dialog('option', 'buttons',
21
+ [
22
+ {
23
+ text: "Continue",
24
+ icons: {
25
+ primary: "ui-icon-heart"
26
+ },
27
+ click: function () {
28
+ window.location.reload();
29
+ }
30
+ }
31
+ ]
32
+ );
26
33
 
27
34
  $("#logout_dialog").dialog("open");
28
35
 
@@ -52,13 +59,20 @@ JS
52
59
  javascript_tag(code)
53
60
  end
54
61
 
62
+ # Generates viewport-covering dialog HTML with message in center
63
+ # options={} are output to HTML. Be CAREFUL about XSS/CSRF!
55
64
  def auto_session_warning_tag(options={})
56
- "<div id='logout_dialog' title='Logout Message' style='display:none;'>
57
- You are about to be logged out of this system.
58
- <br/><br/>
59
- Please click Continue if you want to stay logged in.
60
- </div> <div class='logout_dialog'></div>".html_safe
65
+ default_message = "You are about to be logged out due to inactivity.<br/><br/>Please click &lsquo;Continue&rsquo; to stay logged in."
66
+ html_message = options[:message] || default_message
67
+ warning_title = options[:title] || "Logout Warning"
68
+ warning_classes = !!(options[:classes]) ? ' class="' + options[:classes] + '"' : ''
69
+
70
+ # Marked .html_safe -- Passed strings are output directly to HTML!
71
+ "<div id='logout_dialog' title='#{warning_title}' style='display:none;'#{warning_classes}>
72
+ #{html_message}
73
+ </div>
74
+ <div class='logout_dialog'></div>".html_safe
61
75
  end
62
76
  end
63
77
 
64
- ActionView::Base.send :include, AutoSessionTimeoutWarningHelper
78
+ ActionView::Base.send :include, AutoSessionTimeoutWarningHelper
metadata CHANGED
@@ -1,78 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto-session-timeout-warning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Krishna Srihari
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: minitest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '4.2'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '4.2'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: actionpack
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '3.2'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '3.2'
78
69
  description: jQuery automatic session timeout warning in a Rails application.
@@ -82,7 +73,7 @@ executables: []
82
73
  extensions: []
83
74
  extra_rdoc_files: []
84
75
  files:
85
- - .project
76
+ - ".project"
86
77
  - Gemfile
87
78
  - LICENSE.txt
88
79
  - README.md
@@ -99,27 +90,26 @@ files:
99
90
  homepage: https://github.com/krishnasrihari/auto-session-timeout-warning
100
91
  licenses:
101
92
  - MIT
93
+ metadata: {}
102
94
  post_install_message:
103
95
  rdoc_options: []
104
96
  require_paths:
105
97
  - lib
106
98
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
99
  requirements:
109
- - - ! '>='
100
+ - - ">="
110
101
  - !ruby/object:Gem::Version
111
102
  version: '0'
112
103
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
104
  requirements:
115
- - - ! '>='
105
+ - - ">="
116
106
  - !ruby/object:Gem::Version
117
107
  version: '0'
118
108
  requirements: []
119
109
  rubyforge_project:
120
- rubygems_version: 1.8.24
110
+ rubygems_version: 2.5.1
121
111
  signing_key:
122
- specification_version: 3
112
+ specification_version: 4
123
113
  summary: jQuery automatic session timeout in a Rails application.
124
114
  test_files:
125
115
  - test/auto_session_timeout_warning_helper_test.rb