Commit e924b6952e690cd3f43b64d2c7e8e91acf258c25
1 parent
dc030339
Déconnexion
Showing
3 changed files
with
24 additions
and
3 deletions
Show diff stats
api/commun.php
... | ... | @@ -38,6 +38,7 @@ function donne($parametre) { // Vérifie si le paramètre est donné |
38 | 38 | } |
39 | 39 | |
40 | 40 | function supprimerJeton($jeton) { |
41 | + global $db; | |
41 | 42 | $requete = $db->prepare("DELETE FROM Sessions WHERE jeton=?"); |
42 | 43 | if (!$requete) { |
43 | 44 | retour("erreur_bdd_preparee", ["message" => $db->error]); | ... | ... |
index.html
... | ... | @@ -99,9 +99,9 @@ |
99 | 99 | <a class="breadcrumb" v-if="page == 'gestion'">Gestion</a> |
100 | 100 | </div> |
101 | 101 | <ul class="right hide-on-med-and-down"> |
102 | - <li v-if="connecte"> | |
103 | - <a class="dropdown-button" data-activates="menuUtilisateur"> | |
104 | - <i class="material-icons">perm_identity</i> {{ login }} (<i class="material-icons">timer</i> {{ timer }}) | |
102 | + <li v-if="moi.connecte"> | |
103 | + <a class="dropdown-button" href="#utilisateurs" @click="page = 'gestion'"> | |
104 | + <i class="material-icons">perm_identity</i> {{ moi.login }} (<i class="material-icons">timer</i> {{ timer }}) | |
105 | 105 | </a> |
106 | 106 | </li> |
107 | 107 | <li v-if="connecte && page == 'operations'"> |
... | ... | @@ -321,6 +321,7 @@ |
321 | 321 | <div id="utilisateurs"> |
322 | 322 | <h4>{{ moi.login }}</h4> |
323 | 323 | <umodifier :utilisateur="moi"></umodifier> |
324 | + <button class="orange" @click="deconnecter">Se déconnecter</button> | |
324 | 325 | |
325 | 326 | <h4>Liste des utilisateurs</h4> |
326 | 327 | <button @click="actuUtilisateurs">Rafraîchir</button> | ... | ... |
js/init.js
... | ... | @@ -248,6 +248,22 @@ var app = new Vue({ |
248 | 248 | }) |
249 | 249 | return false |
250 | 250 | }, |
251 | + deconnecter: function() { | |
252 | + var that = this; | |
253 | + this.api("utilisateur/deconnexion", {} , function(retour, donnees) { | |
254 | + switch(retour) { | |
255 | + case "ok": | |
256 | + that.moi = {} | |
257 | + that.page = 'connexion' | |
258 | + break; | |
259 | + | |
260 | + default: | |
261 | + that.erreur(retour, donnees); | |
262 | + break; | |
263 | + } | |
264 | + }) | |
265 | + return false | |
266 | + }, | |
251 | 267 | creer: function() { |
252 | 268 | var that = this |
253 | 269 | this.api("client/ajouter", {idCarte: this.idCarte, solde: this.solde, decouvert: this.decouvert}, function(retour, donnees) { |
... | ... | @@ -314,6 +330,9 @@ var app = new Vue({ |
314 | 330 | computed: { |
315 | 331 | timer: function() { |
316 | 332 | var secondes = this.connecte + JETON_DUREE - this.date |
333 | + if (secondes <= 0) { | |
334 | + this.deconnecter() | |
335 | + } | |
317 | 336 | var minutes = Math.floor(secondes/60) |
318 | 337 | var secondes = secondes % 60 |
319 | 338 | return minutes + ':' + (secondes < 10 ? '0' : '') + secondes | ... | ... |