Skip to content
Snippets Groups Projects

fix missing permissions

Merged Timothee P requested to merge evol/redmine-ticket-11442-permissions into develop
4 files
+ 42
80
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 26
72
@@ -3,7 +3,6 @@ const axios = require("axios");
@@ -3,7 +3,6 @@ const axios = require("axios");
import Vue from 'vue';
import Vue from 'vue';
import Vuex from 'vuex';
import Vuex from 'vuex';
import router from '../router'
import router from '../router'
//import modules from './modules';
import feature_type from "./modules/feature_type"
import feature_type from "./modules/feature_type"
import feature from "./modules/feature"
import feature from "./modules/feature"
import map from "./modules/map"
import map from "./modules/map"
@@ -100,7 +99,7 @@ export default new Vuex.Store({
@@ -100,7 +99,7 @@ export default new Vuex.Store({
project: state => state.projects.find((project) => project.slug === state.project_slug),
project: state => state.projects.find((project) => project.slug === state.project_slug),
permissions: state => state.user_permissions ? state.user_permissions[state.project_slug] : noPermissions,
permissions: state => state.user_permissions ? state.user_permissions[state.project_slug] : noPermissions,
project_types: state => state.projects.filter(projet => projet.is_project_type),
project_types: state => state.projects.filter(projet => projet.is_project_type),
project_user: state => state.projects.filter(projet => projet.creator === state.user.id), // todo: add id to user in api
project_user: state => state.projects.filter(projet => projet.creator === state.user.id),
},
},
actions: {
actions: {
@@ -121,7 +120,7 @@ export default new Vuex.Store({
@@ -121,7 +120,7 @@ export default new Vuex.Store({
throw error;
throw error;
});
});
},
},
GET_STATIC_PAGES({ commit }) {
GET_STATIC_PAGES({ commit }) {
return axios
return axios
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}flat-pages/`)
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}flat-pages/`)
.then((response) => (commit("SET_STATIC_PAGES", response.data)))
.then((response) => (commit("SET_STATIC_PAGES", response.data)))
@@ -162,29 +161,32 @@ export default new Vuex.Store({
@@ -162,29 +161,32 @@ export default new Vuex.Store({
}
}
},
},
USER_INFO({ commit }) {
USER_INFO({ state, commit }) {
return axios
if (state.user) {
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user_info/`)
axios
.then((response) => {
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user_info/`)
if (response && response.status === 200) {
.then((response) => {
const user = response.data.user;
if (response && response.status === 200) {
commit("SET_USER", user);
const user = response.data.user;
window.localStorage.setItem("user", JSON.stringify(user)); //? toujours nécessaire ?
commit("SET_USER", user);
}
window.localStorage.setItem("user", JSON.stringify(user)); //? toujours nécessaire ?
})
}
.catch(() => {
})
router.push({ name: "login" });
.catch(() => {
});
router.push({ name: "login" });
 
});
 
}
},
},
LOGOUT({ commit }) { // ? logout se fait bien dans django ?
LOGOUT({ commit }) {
axios
axios
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}logout/`)
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}logout/`)
.then((response) => {
.then((response) => {
if (response && response.status === 200) {
if (response && response.status === 200) {
commit("SET_USER", false); // ? better false or null
commit("SET_USER", false);
commit("SET_USER_LEVEL_PROJECTS", null);
commit("SET_USER_LEVEL_PROJECTS", null);
commit("SET_USER_PERMISSIONS", null);
commit("SET_USER_PERMISSIONS", null);
 
router.push("/");
}
}
})
})
.catch((error) => {
.catch((error) => {
@@ -204,6 +206,7 @@ export default new Vuex.Store({
@@ -204,6 +206,7 @@ export default new Vuex.Store({
throw error;
throw error;
});
});
},
},
 
GET_USER_LEVEL_PROJECTS({ commit }) {
GET_USER_LEVEL_PROJECTS({ commit }) {
return axios
return axios
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user-level-projects/`)
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user-level-projects/`)
@@ -230,15 +233,12 @@ export default new Vuex.Store({
@@ -230,15 +233,12 @@ export default new Vuex.Store({
});
});
},
},
GET_PROJECT_INFO({ commit, dispatch }, slug) {
GET_PROJECT_INFO({ state, commit, dispatch }, slug) {
commit("SET_PROJECT_SLUG", slug);
commit("SET_PROJECT_SLUG", slug);
return Promise.all([
dispatch("GET_PROJECT_LAST_MESSAGES", slug);
dispatch("GET_PROJECT_LAST_MESSAGES", slug),
dispatch("feature_type/GET_PROJECT_FEATURE_TYPES", slug);
dispatch("feature_type/GET_PROJECT_FEATURE_TYPES", slug),
dispatch("feature/GET_PROJECT_FEATURES", slug);
dispatch("feature/GET_PROJECT_FEATURES", slug),
if (state.user) dispatch("map/GET_BASEMAPS", slug);
dispatch("map/GET_BASEMAPS", slug),
]);
},
},
GET_PROJECT_LAST_MESSAGES({ commit }, project_slug) {
GET_PROJECT_LAST_MESSAGES({ commit }, project_slug) {
@@ -253,52 +253,6 @@ export default new Vuex.Store({
@@ -253,52 +253,6 @@ export default new Vuex.Store({
throw error;
throw error;
});
});
},
},
/* GET_PROJECT_USER({ commit }, project_slug) {
axios
.get(`${DJANGO_API_BASE}projects/${project_slug}/utilisateurs`)
.then((response) => (commit("SET_PROJECT_MEMBERS", response.data.members)))
.catch((error) => {
throw error;
});
}, */
/* GET_PROJECT_FEATURES({ commit }, project_slug) {
axios
.get(`${DJANGO_API_BASE}projects/${project_slug}/feature`)
.then((response) => commit("feature/SET_FEATURES", response.data.features))
.catch((error) => {
throw error;
});
},
*/
/* GET_PROJECT({ commit }, project_slug) {
axios
.get(`${DJANGO_API_BASE}projects/${project_slug}/project`)
.then((response) => commit("SET_PROJECT", response.data))
.catch((error) => {
throw error;
});
},
*/
/* GET_COOKIE({ commit }, name) {
let cookieValue = null;
if (document.cookie && document.cookie !== "") {
const cookies = document.cookie.split(";");
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === name + "=") {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
commit("SET_COOKIE", cookieValue);
}, */
}
}
});
});
Loading