]> rtime.felk.cvut.cz Git - coffee/coffee-flask.git/commitdiff
Make on-screen buttons work only once after card swipe
authorMichal Sojka <michal.sojka@cvut.cz>
Wed, 8 Aug 2018 11:36:32 +0000 (13:36 +0200)
committerMichal Sojka <michal.sojka@cvut.cz>
Wed, 8 Aug 2018 11:36:32 +0000 (13:36 +0200)
Now, even if a user does not log out, there is no way for somebody
else to charge coffees on their behalf.

templates/main.js

index 624015cc9dafc2297272ba2e8495d79bbad34719..11320ef87655aa310e31a418ebf749698dfafd15 100644 (file)
@@ -61,8 +61,6 @@ function hiddenUpdateRemote(json) {
                 var flavor = getFlavor(msg.key);
                 if (flavor !== "") {
                     addCoffee(flavor);
-                   flavorChosen = flavor;
-                    loggedIn = false;
                 }
             }
             break;
@@ -163,7 +161,11 @@ function addCoffee(flavor) {
         time: new Date().toISOString(),
         flavor: flavor
     });
-    ajax("POST", "coffee/add", data, "user");
+    if (loggedIn) {
+        ajax("POST", "coffee/add", data, "user");
+        flavorChosen = flavor;
+        loggedIn = false;
+    }
 }
 
 function sendLog(json) {