auto-session-timeout-warning 0.1.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -19,12 +19,36 @@ Or install it yourself as:
19
19
  $ gem install auto-session-timeout-warning
20
20
 
21
21
  ## Usage
22
- Add jquery and jquery-ui on your application.js file
22
+ 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
+
24
+ Add before_timedout_action in application controller
25
+
26
+ ```
27
+ class ApplicationController < ActionController::Base
28
+ #Add protected before_timedout action
29
+ before_timedout_action
30
+ end
31
+ ```
32
+
33
+ If you want to override the before_timedout, just add protected before_timedout action and add your custom implementation here
34
+ ```
35
+ class ApplicationController < ActionController::Base
36
+ before_timedout_action
37
+
38
+ protected
39
+ #override before_timedout
40
+ def before_timedout
41
+ #your custom code here
42
+ end
43
+ end
44
+ ```
45
+
46
+ and follow all steps as for https://github.com/pelargir/auto-session-timeout.
23
47
 
24
- and follow all usage steps as for https://github.com/pelargir/auto-session-timeout.
25
48
 
26
49
  Check below configuration for warning message
27
50
 
51
+
28
52
  ## Warning message Configuration
29
53
  <html>
30
54
  <head>...</head>
@@ -52,8 +76,6 @@ start: 60,
52
76
  warning: 20
53
77
 
54
78
  ## TODO
55
-
56
- * current_user must be defined
57
79
  * setting timeout in controller vs. user
58
80
 
59
81
  ## Contributing
@@ -2,7 +2,7 @@ module Auto
2
2
  module Session
3
3
  module Timeout
4
4
  module Warning
5
- VERSION = "0.1.3"
5
+ VERSION = "1.0.0"
6
6
  end
7
7
  end
8
8
  end
@@ -9,6 +9,7 @@ module AutoSessionTimeoutWarning
9
9
  def auto_session_timeout(seconds=nil)
10
10
  prepend_before_filter do |c|
11
11
  if c.session[:auto_session_expires_at] && c.session[:auto_session_expires_at] < Time.now
12
+ c.send :before_timedout
12
13
  c.send :reset_session
13
14
  else
14
15
  unless c.url_for(c.params).start_with?(c.send(:active_url))
@@ -23,6 +24,11 @@ module AutoSessionTimeoutWarning
23
24
  define_method(:active) { render_session_status }
24
25
  define_method(:timeout) { render_session_timeout }
25
26
  end
27
+
28
+ def before_timedout_action
29
+ define_method(:before_timedout){}
30
+ send(:protected, :before_timedout)
31
+ end
26
32
  end
27
33
 
28
34
  def render_session_status
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.3
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: