fix: make sure the app is fully ready before trying to redirect to the login page #1337
|
@ -53,7 +53,7 @@ import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
|||
import {useOnline} from '@/composables/useOnline'
|
||||
|
||||
import {useRouter, useRoute} from 'vue-router'
|
||||
import {checkAuth} from '@/router'
|
||||
import {getAuthForRoute} from '@/router'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
@ -69,7 +69,7 @@ const showLoading = computed(() => !ready.value && error.value === '')
|
|||
async function load() {
|
||||
try {
|
||||
await store.dispatch('loadApp')
|
||||
const redirectTo = checkAuth(route)
|
||||
const redirectTo = getAuthForRoute(route)
|
||||
if (typeof redirectTo !== 'undefined') {
|
||||
await router.push(redirectTo)
|
||||
dpschen marked this conversation as resolved
|
||||
}
|
||||
|
|
|
@ -575,7 +575,7 @@ const router = createRouter({
|
|||
],
|
||||
})
|
||||
|
||||
export function checkAuth(route: RouteLocation) {
|
||||
export function getAuthForRoute(route: RouteLocation) {
|
||||
const authUser = store.getters['auth/authUser']
|
||||
const authLinkShare = store.getters['auth/authLinkShare']
|
||||
|
||||
|
|
Reference in New Issue
Block a user
I wanted to make sure the app would only be ready after it was redirected. What bothers me here is I had to move the
store.commit('vikunjaReady', true)
out of theloadApp
action. It should be fine since this is the only place where that action is used, but I'm not quite sure about it.Can you give a bit more context what you mean by:
That was meant the other way around - "...make sure the app would only redirect after it was ready"
See my lenghty comment below.
Ahh that makes more sense. I really broke my mind on this one :D