session-check 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -2,8 +2,14 @@ require 'devise'
|
|
2
2
|
|
3
3
|
module SessionCheckHelper
|
4
4
|
|
5
|
-
def session_check
|
6
|
-
|
5
|
+
def session_check(options)
|
6
|
+
locals = {
|
7
|
+
session_time: Devise.timeout_in,
|
8
|
+
check_every: 10,
|
9
|
+
reset_counter_on_ajax: true,
|
10
|
+
logged_out_url: '/users/sign_in'
|
11
|
+
}.merge options
|
12
|
+
render :partial => '/session_check', locals: locals
|
7
13
|
end
|
8
14
|
|
9
15
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<script>
|
2
2
|
var should_session_check = <%= !current_user.nil? %>;
|
3
3
|
(function () {
|
4
|
-
var check_every_s =
|
4
|
+
var check_every_s = <%= check_every %>;
|
5
5
|
var session_time_left = <%= session_time %>;
|
6
6
|
var force_sign_in = function () {
|
7
|
-
window.location = '
|
7
|
+
window.location = '<%= logged_out_url %>';
|
8
8
|
};
|
9
9
|
var session_check = function () {
|
10
10
|
session_time_left = session_time_left - check_every_s;
|
@@ -20,10 +20,12 @@
|
|
20
20
|
setTimeout(session_check, check_every_s * 1000);
|
21
21
|
};
|
22
22
|
setTimeout(session_check, check_every_s * 1000);
|
23
|
+
<% if reset_counter_on_ajax %>
|
23
24
|
$.ajaxSetup({
|
24
25
|
complete: function (xhr) {
|
25
26
|
session_time_left = <%= session_time %>;
|
26
27
|
}
|
27
28
|
});
|
29
|
+
<% end %>
|
28
30
|
}());
|
29
31
|
</script>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: session-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
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-
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|