From 25fbebf3263aeef050868669d08bd49ab36b1385 Mon Sep 17 00:00:00 2001
From: nicrausaz <n.crausaz99@gmail.com>
Date: Wed, 26 Jun 2019 16:30:56 +0200
Subject: [PATCH] Fix date de connexion

---
 canapGEST/Site/src/App.vue                         |  4 +++-
 canapGEST/Site/src/store/modules/user/actions.js   | 14 +++-----------
 canapGEST/Site/src/store/modules/user/mutations.js |  6 +++---
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/canapGEST/Site/src/App.vue b/canapGEST/Site/src/App.vue
index ba51bbc..0398ac3 100644
--- a/canapGEST/Site/src/App.vue
+++ b/canapGEST/Site/src/App.vue
@@ -19,7 +19,7 @@ import MainFooter from '@/layouts/MainFooter.vue'
 import alertSnackbar from '@/components/alertSnackbar.vue'
 
 export default {
-  created() {
+  created () {
     let key = null
     if (location.hash !== '#/') {
       key = location.hash.replace('#/?key=', '')
@@ -29,6 +29,8 @@ export default {
     }
     if (!this.$store.getters['moduleUser/userIsLogedIn']) {
       this.$store.dispatch('moduleUser/login', key)
+    } else {
+      this.$store.dispatch('moduleUser/getLastConnection')
     }
   },
   components: {
diff --git a/canapGEST/Site/src/store/modules/user/actions.js b/canapGEST/Site/src/store/modules/user/actions.js
index b44d0bd..7c37f26 100644
--- a/canapGEST/Site/src/store/modules/user/actions.js
+++ b/canapGEST/Site/src/store/modules/user/actions.js
@@ -15,20 +15,12 @@ export function login (context, key) {
 export function logout (context, fullLogout) {
   localStorage.removeItem('stored_token')
   if (fullLogout) {
-    // set last conn ?
-    window.location = 'https://tequila.epfl.ch/logout'
+    setLastConnection().then(() => {
+      window.location = 'https://tequila.epfl.ch/logout'
+    })
   } else {
     location.reload()
   }
-  // setLastConnection().then(() => {
-  //   console.log('test')
-  //   localStorage.removeItem('stored_token')
-  //   if (fullLogout) {
-  //     window.location = 'https://tequila.epfl.ch/logout'
-  //   } else {
-  //     location.reload()
-  //   }
-  // })
 }
 
 export function getUserData (context) {
diff --git a/canapGEST/Site/src/store/modules/user/mutations.js b/canapGEST/Site/src/store/modules/user/mutations.js
index a15c49d..ace89d3 100644
--- a/canapGEST/Site/src/store/modules/user/mutations.js
+++ b/canapGEST/Site/src/store/modules/user/mutations.js
@@ -1,11 +1,11 @@
-export function setUserData(state, data) {
+export function setUserData (state, data) {
   state.userData = data
 }
 
-export function setPermittedJobs(state, data) {
+export function setPermittedJobs (state, data) {
   state.permittedJobs = data
 }
 
-export function setLastConnection(state, data) {
+export function setLastConnection (state, data) {
   state.lastConnection = data
 }
\ No newline at end of file
-- 
GitLab