diff --git a/src/store/index.js b/src/store/index.js index dec5ece0..c60e0ebf 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2,7 +2,6 @@ import {createStore} from 'vuex' import { BACKGROUND, CURRENT_LIST, - ERROR_MESSAGE, HAS_TASKS, KEYBOARD_SHORTCUTS_ACTIVE, LOADING, @@ -36,7 +35,6 @@ export const store = createStore({ state: { loading: false, loadingModule: null, - errorMessage: '', online: true, // This is used to highlight the current list in menu for all list related views currentList: {id: 0}, @@ -53,9 +51,6 @@ export const store = createStore({ [LOADING_MODULE](state, module) { state.loadingModule = module }, - [ERROR_MESSAGE](state, error) { - state.errorMessage = error - }, [ONLINE](state, online) { if (import.meta.env.VITE_IS_ONLINE) { console.log('Setting fake online state', import.meta.env.VITE_IS_ONLINE) diff --git a/src/store/modules/auth.js b/src/store/modules/auth.js index 2d5bbec8..19d4ba11 100644 --- a/src/store/modules/auth.js +++ b/src/store/modules/auth.js @@ -1,5 +1,5 @@ import {HTTPFactory} from '@/http-common' -import {ERROR_MESSAGE, LOADING} from '../mutation-types' +import {LOADING} from '../mutation-types' import UserModel from '../../models/user' import {getToken, refreshToken, removeToken, saveToken} from '@/helpers/auth' @@ -128,8 +128,8 @@ export default { }) return ctx.dispatch('login', credentials) } catch(e) { - if (e.response && e.response.data && e.response.data.message) { - ctx.commit(ERROR_MESSAGE, e.response.data.message, {root: true}) + if (e.response?.data?.message) { + throw e.response.data } throw e diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js index aff9ba40..7c37ee6c 100644 --- a/src/store/mutation-types.js +++ b/src/store/mutation-types.js @@ -1,6 +1,5 @@ export const LOADING = 'loading' export const LOADING_MODULE = 'loadingModule' -export const ERROR_MESSAGE = 'errorMessage' export const ONLINE = 'online' export const CURRENT_LIST = 'currentList' export const HAS_TASKS = 'hasTasks' diff --git a/src/views/user/Login.vue b/src/views/user/Login.vue index 3f5d4fdf..0ad4dac0 100644 --- a/src/views/user/Login.vue +++ b/src/views/user/Login.vue @@ -105,7 +105,7 @@ import {mapState} from 'vuex' import {HTTPFactory} from '@/http-common' -import {ERROR_MESSAGE, LOADING} from '@/store/mutation-types' +import {LOADING} from '@/store/mutation-types' import legal from '../../components/misc/legal' import ApiConfig from '@/components/misc/api-config.vue' import {getErrorText} from '@/message' @@ -121,6 +121,7 @@ export default { return { confirmedEmailSuccess: false, hasApiUrl: false, + errorMessage: '', } }, beforeMount() { @@ -138,7 +139,7 @@ export default { }) .catch(e => { cancel() - this.$store.commit(ERROR_MESSAGE, e.response.data.message) + this.errorMessage = e.response.data.message }) } @@ -170,7 +171,6 @@ export default { ...mapState({ registrationEnabled: state => state.config.registrationEnabled, loading: LOADING, - errorMessage: ERROR_MESSAGE, needsTotpPasscode: state => state.auth.needsTotpPasscode, authenticated: state => state.auth.authenticated, localAuthEnabled: state => state.config.auth.local.enabled, @@ -189,7 +189,7 @@ export default { }, async submit() { - this.$store.commit(ERROR_MESSAGE, '') + this.errorMessage = '' // Some browsers prevent Vue bindings from working with autofilled values. // To work around this, we're manually getting the values here instead of relying on vue bindings. // For more info, see https://kolaente.dev/vikunja/frontend/issues/78 @@ -211,12 +211,7 @@ export default { } const err = getErrorText(e) - if (typeof err[1] !== 'undefined') { - this.$store.commit(ERROR_MESSAGE, err[1]) - return - } - - this.$store.commit(ERROR_MESSAGE, err[0]) + this.errorMessage = typeof err[1] !== 'undefined' ? err[1] : err[0] } }, diff --git a/src/views/user/OpenIdAuth.vue b/src/views/user/OpenIdAuth.vue index 148c1129..93b421b3 100644 --- a/src/views/user/OpenIdAuth.vue +++ b/src/views/user/OpenIdAuth.vue @@ -12,14 +12,18 @@