Browse Source

Update error handling

pull/1274/head
Hironsan 3 years ago
parent
commit
e1bf8d156e
2 changed files with 16 additions and 13 deletions
  1. 19
      frontend/components/auth/FormLogin.vue
  2. 10
      frontend/store/auth.js

19
frontend/components/auth/FormLogin.vue

@ -68,17 +68,16 @@ export default Vue.extend({
},
methods: {
tryLogin() {
this.login({
username: this.username,
password: this.password
})
.then(() => {
this.$router.push(this.localePath('/projects'))
})
.catch(() => {
this.showError = true
async tryLogin() {
try {
await this.login({
username: this.username,
password: this.password
})
this.$router.push(this.localePath('/projects'))
} catch {
this.showError = true
}
}
}
})

10
frontend/store/auth.js

@ -25,9 +25,13 @@ export const getters = {
}
export const actions = {
authenticateUser({ commit }, authData) {
this.$services.auth.login(authData.username, authData.password)
commit('setAuthenticated', true)
async authenticateUser({ commit }, authData) {
try {
await this.$services.auth.login(authData.username, authData.password)
commit('setAuthenticated', true)
} catch(error) {
throw new Error('The credential is invalid')
}
},
async initAuth({ commit }) {
try {

Loading…
Cancel
Save