]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/commitdiff
Logout automatically even without selecting any beverage
authorMichal <michal.sojka@cvut.cz>
Wed, 15 Aug 2018 10:14:06 +0000 (12:14 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Thu, 16 Aug 2018 18:05:15 +0000 (20:05 +0200)
When a user logs in, and no beverage is selected within 120 seconds,
she are logged out automatically.

The main purpose for this functionality that when somebody swipes a
card in the offline mode and than goes away, because she does not see
nice graph. When the server is online again, the offline-collected
data is replayed and the user would stay logged in forever.

templates/main.js

index 034fcfa96f28bc8262158d8f5d4d9cae3857f543..b55fbb5c12d047d0635e5d24b2cf5075deea613a 100644 (file)
@@ -148,8 +148,7 @@ function ajax(method, route, data, id) {
 function login(id) {
     ajax("POST", "login", id, "user");
     id_user = id;
-    clearTimeout(logoutTimer);
-    timeToLogout = undefined;
+    countingTimeLogout(120);
 }
 
 function logout() {
@@ -161,6 +160,7 @@ function logout() {
 
 function countingTimeLogout(count_time)
 {
+    clearTimeout(logoutTimer);
     timeToLogout = count_time;
     updateUI();
     if (count_time == 0) {