Internal: Fix login, return error message

pull/3696/head
Julio Montoya 4 years ago
parent 68897a0a8d
commit 953c0fbab4
  1. 3
      assets/vue/App.vue
  2. 1
      assets/vue/store/index.js
  3. 9
      assets/vue/store/security.js
  4. 18
      assets/vue/views/Login.vue

@ -178,7 +178,8 @@ export default {
axios.interceptors.response.use(undefined, (err) => {
return new Promise(() => {
if (err.response.status === 401) {
this.$router.push({path: "/login"})
// Redirect to the login if status 401.
this.$router.push({path: "/login"}).catch(()=>{});
} else if (err.response.status === 500) {
document.open();
document.write(err.response.data);

@ -11,6 +11,5 @@ export default new Vuex.Store({
modules: {
notifications,
security: SecurityModule,
//session,
}
});

@ -71,15 +71,12 @@ export default {
actions: {
async login({commit}, payload) {
commit(AUTHENTICATING);
try {
let response = await SecurityAPI.login(payload.login, payload.password);
await SecurityAPI.login(payload.login, payload.password).then(response => {
commit(AUTHENTICATING_SUCCESS, response.data);
return response.data;
} catch (error) {
console.log(error);
}).catch(error => {
commit(AUTHENTICATING_ERROR, error);
return null;
}
});
},
onRefresh({commit}, payload) {
commit(PROVIDING_DATA_ON_REFRESH_SUCCESS, payload);

@ -41,6 +41,20 @@
</b-button>
</div>
<div
v-if="isLoading"
class="row col"
>
<p><font-awesome-icon icon="spinner" /></p>
</div>
<div
v-else-if="hasError"
class="row col"
>
<error-message :error="error" />
</div>
<a href="/main/auth/lostPassword.php" id="forgot">Forgot password?</a>
</form>
</b-col>
@ -88,8 +102,8 @@
this.performLogin();
},
async performLogin() {
let payload = {login: this.$data.login, password: this.$data.password},
redirect = this.$route.query.redirect;
let payload = {login: this.$data.login, password: this.$data.password};
let redirect = this.$route.query.redirect;
await this.$store.dispatch("security/login", payload);
if (!this.$store.getters["security/hasError"]) {
if (typeof redirect !== "undefined") {

Loading…
Cancel
Save