diff --git a/src/store/index.js b/src/store/index.js index 225a436baf70bef89896a64b107a05b8ab33f0c1..5035d682a0b278a2279c895d9deb3318b400fd56 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -162,14 +162,14 @@ export default new Vuex.Store({ }, USER_INFO({ state, commit }) { - if (state.user) { + if (!state.user) { axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user_info/`) .then((response) => { if (response && response.status === 200) { const user = response.data.user; commit("SET_USER", user); - window.localStorage.setItem("user", JSON.stringify(user)); //? toujours nécessaire ? + //window.localStorage.setItem("user", JSON.stringify(user)); // ? nécessaire ? } }) .catch(() => { @@ -178,16 +178,17 @@ export default new Vuex.Store({ } }, - LOGOUT({ commit }) { - const pageNoRedirect = ["liste-signalements", "details-type-signalement", "details-signalement", "project_detail", "mentions", "aide", "index"] + LOGOUT({ commit, dispatch }) { + // const pageNoRedirect = ["liste-signalements", "details-type-signalement", "details-signalement", "project_detail", "mentions", "aide", "index"] axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}logout/`) .then((response) => { if (response && response.status === 200) { commit("SET_USER", false); commit("SET_USER_LEVEL_PROJECTS", null); - commit("SET_USER_PERMISSIONS", null); - if (!pageNoRedirect.includes(router.history.current.name)) router.push("/"); + dispatch("GET_USER_LEVEL_PERMISSIONS"); + // if (!pageNoRedirect.includes(router.history.current.name)) router.push("/"); + router.push("/"); } }) .catch((error) => { diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue index a07d84208e8459b9466ed6ed758183399a48a763..5b1ae27e3f65b90c44e20d740d325863413903a8 100644 --- a/src/views/project/Project_detail.vue +++ b/src/views/project/Project_detail.vue @@ -530,7 +530,7 @@ export default { }, mounted() { - if (this.project) { + if (this.project && this.permissions.can_view_project) { this.$store.dispatch("map/INITIATE_MAP"); const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; let self = this;