From: Michal Date: Wed, 15 Aug 2018 10:14:06 +0000 (+0200) Subject: Logout automatically even without selecting any beverage X-Git-Url: http://rtime.felk.cvut.cz/gitweb/coffee/coffee-flask.git/commitdiff_plain/b23920472e87f5b504b11c6ab44434debab3b79f Logout automatically even without selecting any beverage 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. --- diff --git a/templates/main.js b/templates/main.js index 034fcfa..b55fbb5 100644 --- a/templates/main.js +++ b/templates/main.js @@ -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) {