Skip to content
Snippets Groups Projects
Commit 21be08d7 authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'anom/redmine-ticket-11714-connexion-error-message' into 'develop'

Anom/redmine ticket 11714 connexion error message

See merge request geocontrib/geocontrib-frontend!56
parents e2656a7c 11092b92
No related branches found
No related tags found
1 merge request!56Anom/redmine ticket 11714 connexion error message
......@@ -184,8 +184,9 @@ export default {
return {
menuIsOpen: false,
rightMenuIsOpen: true,
messages: null,
width: window.innerWidth > 0 ? window.innerWidth : screen.width,
messages: [/* {
comment: "TEST"
} */],
};
},
......
......@@ -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) => {
......
......@@ -26,7 +26,6 @@
</div>
<form class="ui form" role="form" type="post" @submit.prevent="login">
<div class="ui stacked secondary segment">
<div class="six field required">
<div class="ui left icon input">
......@@ -62,8 +61,6 @@
<script>
import { mapState } from "vuex";
export default {
name: "Login",
data() {
......@@ -77,33 +74,32 @@ export default {
};
},
computed: {
...mapState(["error"]),
LOGO_PATH:function () {
LOGO_PATH: function () {
return this.$store.state.configuration.VUE_APP_LOGO_PATH;
},
APPLICATION_NAME: function () {
return this.$store.state.configuration.VUE_APP_APPLICATION_NAME;
},
APPLICATION_ABSTRACT:function () {
APPLICATION_ABSTRACT: function () {
return this.$store.state.configuration.VUE_APP_APPLICATION_ABSTRACT;
},
},
methods: {
async login() {
this.$store.dispatch("LOGIN", {
username: this.username_value,
password: this.password_value,
})
.then(() => {
if (this.error != null){
this.form.errors = "Les informations d'identification sont incorrectes.";
}
})
.catch(() => {
this.form.errors = this.error
});
login() {
this.$store
.dispatch("LOGIN", {
username: this.username_value,
password: this.password_value,
})
.then((status) => {
if (status === 200) {
this.form.errors = null;
} else if (status === "error") {
this.form.errors = status;
}
})
.catch();
},
},
};
</script>
\ No newline at end of file
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