auto-session-timeout-warning 0.1.0 → 0.1.1
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.
- data/README.md +27 -69
- data/auto-session-timeout-warning.gemspec +1 -1
- data/lib/auto/session/timeout/warning/version.rb +1 -1
- metadata +1 -2
data/README.md
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
# auto-session-timeout
|
1
|
+
# auto-session-timeout-warning
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
online banking sites use this technique. If your app is used on any
|
7
|
-
kind of public computer system, this plugin is a necessity.
|
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
|
5
|
+
https://github.com/pelargir/auto-session-timeout
|
8
6
|
|
9
7
|
## Installation
|
10
8
|
|
11
9
|
Add this line to your application's Gemfile:
|
12
10
|
|
13
|
-
gem 'auto-session-timeout'
|
11
|
+
gem 'auto-session-timeout-warning'
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
@@ -18,82 +16,44 @@ And then execute:
|
|
18
16
|
|
19
17
|
Or install it yourself as:
|
20
18
|
|
21
|
-
$ gem install auto-session-timeout
|
19
|
+
$ gem install auto-session-timeout-warning
|
22
20
|
|
23
21
|
## Usage
|
22
|
+
Add jquery and jquery-ui on your application.js file
|
24
23
|
|
25
|
-
|
24
|
+
and follow all usage steps as for https://github.com/pelargir/auto-session-timeout.
|
26
25
|
|
27
|
-
|
28
|
-
auto_session_timeout 1.hour
|
29
|
-
...
|
30
|
-
end
|
31
|
-
|
32
|
-
You will also need to insert this line inside the body tags in your
|
33
|
-
views. The easiest way to do this is to insert it once inside your
|
34
|
-
default or application-wide layout. Make sure you are only rendering
|
35
|
-
it if the user is logged in, otherwise the plugin will attempt to force
|
36
|
-
non-existent sessions to timeout, wreaking havoc:
|
37
|
-
|
38
|
-
<body>
|
39
|
-
<% if current_user %>
|
40
|
-
<%= auto_session_timeout_js %>
|
41
|
-
<% end %>
|
42
|
-
</body>
|
43
|
-
|
44
|
-
You need to setup two actions: one to return the session status and
|
45
|
-
another that runs when the session times out. You can use the default
|
46
|
-
actions included with the plugin by inserting this line in your target
|
47
|
-
controller (most likely your user or session controller):
|
48
|
-
|
49
|
-
class SessionsController < ApplicationController
|
50
|
-
auto_session_timeout_actions
|
51
|
-
end
|
52
|
-
|
53
|
-
To customize the default actions, simply override them. You can call
|
54
|
-
the render_session_status and render_session_timeout methods to use
|
55
|
-
the default implementation from the plugin, or you can define the
|
56
|
-
actions entirely with your own custom code:
|
57
|
-
|
58
|
-
class SessionsController < ApplicationController
|
59
|
-
def active
|
60
|
-
render_session_status
|
61
|
-
end
|
62
|
-
|
63
|
-
def timeout
|
64
|
-
render_session_timeout
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
In any of these cases, make sure to properly map the actions in
|
69
|
-
your routes.rb file:
|
70
|
-
|
71
|
-
match 'active' => 'sessions#active', via: :get
|
72
|
-
match 'timeout' => 'sessions#timeout', via: :get
|
73
|
-
|
74
|
-
You're done! Enjoy watching your sessions automatically timeout.
|
75
|
-
|
76
|
-
## Additional Configuration
|
77
|
-
|
78
|
-
By default, the JavaScript code checks the server every 60 seconds for
|
79
|
-
active sessions. If you prefer that it check more frequently, pass a
|
80
|
-
frequency attribute to the helper method. The frequency is given in
|
81
|
-
seconds. The following example checks the server every 15 seconds:
|
26
|
+
Check below configuration for warning message
|
82
27
|
|
28
|
+
## Warning message Configuration
|
83
29
|
<html>
|
84
30
|
<head>...</head>
|
85
31
|
<body>
|
86
32
|
<% if current_user %>
|
87
|
-
<%= auto_session_timeout_js frequency:
|
33
|
+
<%= auto_session_timeout_js timeout: 60, frequency: 60, start: 60, warning: 20 %>
|
88
34
|
<% end %>
|
89
35
|
...
|
90
36
|
</body>
|
91
37
|
</html>
|
92
38
|
|
39
|
+
frequency refers to how frequently browser interactive with server to find the session details,
|
40
|
+
|
41
|
+
timeout refers to auto session time out, if you set auto_session_timeout: 2.minutes on application_controller, you should set 120 seconds here,
|
42
|
+
|
43
|
+
start describes the starting time of server interaction, if it is 60, first server interaction will start after 60 seconds,
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
Default values here:
|
48
|
+
|
49
|
+
timeout: 60,
|
50
|
+
frequecy: 60,
|
51
|
+
start: 60,
|
52
|
+
warning: 20
|
53
|
+
|
93
54
|
## TODO
|
94
55
|
|
95
56
|
* current_user must be defined
|
96
|
-
* using Prototype vs. jQuery
|
97
57
|
* setting timeout in controller vs. user
|
98
58
|
|
99
59
|
## Contributing
|
@@ -106,6 +66,4 @@ seconds. The following example checks the server every 15 seconds:
|
|
106
66
|
|
107
67
|
## Resources
|
108
68
|
|
109
|
-
* Repository: http://github.com/pelargir/auto-session-timeout/
|
110
|
-
* Blog: http://www.matthewbass.com
|
111
|
-
* Author: Matthew Bass
|
69
|
+
* Source Repository: http://github.com/pelargir/auto-session-timeout/
|
@@ -6,7 +6,7 @@ require 'auto/session/timeout/warning/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "auto-session-timeout-warning"
|
8
8
|
spec.version = Auto::Session::Timeout::Warning::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["Krishna Srihari"]
|
10
10
|
spec.email = ["krishna.srihari@gmail.com"]
|
11
11
|
spec.description = %q{jQuery automatic session timeout warning in a Rails application.}
|
12
12
|
spec.summary = %q{jQuery automatic session timeout in a Rails application.}
|
metadata
CHANGED