diff --git a/src/stores/authStore.js b/src/stores/authStore.js index 99738e8..b71edec 100644 --- a/src/stores/authStore.js +++ b/src/stores/authStore.js @@ -21,6 +21,7 @@ export const useAuthStore = defineStore({ await this.getGroup($api); router.push({ name: this.returnUrl || "home" }); } catch (error) { + if (!error.response) throw "The server encountered an error"; if (error.response.status == 401) { throw "Incorrect username or password"; } diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index af58877..2c8a2c7 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -6,7 +6,8 @@ let password = ref(""); let loginError = ref(""); const $api = inject("$api"); -async function handleLogin() { +async function handleLogin(e) { + e.preventDefault(); const authStore = useAuthStore(); try { await authStore.login(username, password, $api); @@ -33,7 +34,7 @@ async function handleLogin() { input.input(v-model="password" type="password" placeholder="password") span.icon.is-small.is-left font-awesome-icon(icon="fas fa-lock") - button.button.fancy-button.is-fullwidth(type="submit" @click="handleLogin()") Log In + button.button.fancy-button.is-fullwidth(type="submit" @click="handleLogin") Log In .has-text-danger p {{ loginError }}