Skip to content
Snippets Groups Projects

Anom/redmine ticket 11714 connexion error message

Merged Timothee P requested to merge anom/redmine-ticket-11714-connexion-error-message into develop
3 files
+ 25
34
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 6
12
@@ -37,7 +37,6 @@ export default new Vuex.Store({
map
},
state: {
error: null,
logged: false,
user: false,
configuration: null,
@@ -51,9 +50,6 @@ export default new Vuex.Store({
},
mutations: {
error(state, data) {
state.error = data;
},
SET_PROJECTS(state, projects) {
state.projects = projects;
},
@@ -131,14 +127,13 @@ export default new Vuex.Store({
LOGIN({ commit, dispatch }, payload) {
if (payload.username && payload.password) {
axios
return axios
.post(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}login/`, {
username: payload.username,
password: payload.password,
})
.then((response) => {
commit('error', null);
if (response && response.status === 200) {
if (response.status === 200 && response.data) {
// * use stored previous route to go back after login if page not open on login at first
let routerHistory = '';
if (router.options.routerHistory[0] !== undefined) {
@@ -150,13 +145,12 @@ export default new Vuex.Store({
router.push(routerHistory[routerHistory.length - 1] || "/");
dispatch("GET_USER_LEVEL_PROJECTS");
dispatch("GET_USER_LEVEL_PERMISSIONS")
return response.status
}
})
.catch((error) => {
if (error.response.status === 403) {
commit('error', error.response.data.detail);
}
.catch(() => {
commit("SET_USER", false);
return "error";
});
}
},
@@ -188,7 +182,7 @@ export default new Vuex.Store({
commit("SET_USER_LEVEL_PROJECTS", null);
dispatch("GET_USER_LEVEL_PERMISSIONS");
// if (!pageNoRedirect.includes(router.history.current.name)) router.push("/");
router.push("/");
if (router.history.current.name !== "index") router.push("/");
}
})
.catch((error) => {
Loading