rails-automaticlogout 0.2.0 → 0.2.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c8e1435e67f34868aa59b47da980d0314ed0b39
|
4
|
+
data.tar.gz: 49647ce23fdbc6c37a488061ccc0b2fe7fcadcef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92a73343a68b45a2384cf0fa95210ffcc89e3acaefc33221e870ba5127e25c13b876e9b7f806a37c01ccdf84074a9689c1a43dad83dcc31f634125dc42a72350
|
7
|
+
data.tar.gz: 72886b67e1a151ffaa4d58e06314ee62f0e1e83256fcb5f4fe87d60eae64e58095a07604346e5cde8b4919ba1a985c022a8b0f89d2bd3fdec660b37ebfcfbe54
|
@@ -32,8 +32,7 @@ AutomaticLogout.regressiveTimer = function(){;
|
|
32
32
|
* @param {[type]} '.regressive-timer' [description]
|
33
33
|
* @return {[type]} [description]
|
34
34
|
*/
|
35
|
-
var
|
36
|
-
data_message = $('.regressive-timer').data('message'),
|
35
|
+
var data_message = $('.regressive-timer').data('message'),
|
37
36
|
data_seconds = $('.regressive-timer').data('seconds'),
|
38
37
|
current_time = new Date().getTime();
|
39
38
|
|
@@ -124,18 +123,21 @@ AutomaticLogout.ajaxSessionTimeout = function(){
|
|
124
123
|
$.ajax({
|
125
124
|
url: '/status_automatic_logout',
|
126
125
|
success: function(data) {
|
127
|
-
if (data.
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
126
|
+
if (data.seconds !== "null" && data.live === true){
|
127
|
+
|
128
|
+
var data_message = data.message, data_seconds = data.seconds;
|
129
|
+
|
130
|
+
var timerDecrement = setInterval(function(){
|
131
|
+
if (data_seconds == 0) {
|
132
|
+
clearInterval(timerDecrement);
|
133
|
+
// limpa a sessão após o ok do alertify
|
134
134
|
alertify.alert(data_message, function () {
|
135
|
-
|
135
|
+
AutomaticLogout.destroySession();
|
136
136
|
});
|
137
137
|
}
|
138
|
-
|
138
|
+
|
139
|
+
data_seconds -= 1;
|
140
|
+
}, 1000)
|
139
141
|
}
|
140
142
|
}
|
141
143
|
});
|
@@ -15,21 +15,17 @@ module Rails::AutomaticLogout
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def expires_at_in_seconds(time)
|
18
|
-
# ((current_time + time)).strftime("%s").to_i
|
19
18
|
time.seconds.to_i
|
20
19
|
end
|
21
20
|
|
22
21
|
module ClassMethods
|
23
22
|
def automatic_logout_at(time: 1.hour, message: "Session expired! You will be redirect.")
|
24
23
|
prepend_before_filter do |c|
|
25
|
-
if
|
26
|
-
c.
|
24
|
+
if current_user
|
25
|
+
c.session[:seconds] = expires_at_in_seconds(time)
|
26
|
+
c.session[:message] = message
|
27
27
|
else
|
28
|
-
|
29
|
-
c.session[:auto_session_expires_at] = expires_at(time)
|
30
|
-
c.session[:seconds] = expires_at_in_seconds(time)
|
31
|
-
c.session[:message] = message
|
32
|
-
end
|
28
|
+
c.send :reset_session
|
33
29
|
end
|
34
30
|
end
|
35
31
|
end
|