Skip to content
Snippets Groups Projects
Commit 379ac529 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

fix login if no user and reload permissions after logout

parent f25aa074
No related branches found
No related tags found
1 merge request!36fix login if no user and reload permissions after logout
......@@ -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) => {
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment