Skip to content
Snippets Groups Projects

fix login if no user and reload permissions after logout

Merged Timothee P requested to merge evol/redmine-ticket-11797-deconnection into develop
2 files
+ 8
7
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 7
6
@@ -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) => {
Loading