1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-19 07:19:58 +00:00

fix: sign-out and empty content (#1654)

This commit is contained in:
Joaquín Sánchez 2023-02-06 13:16:24 +01:00 committed by GitHub
parent 6e7ac24821
commit f7a8d471a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,5 @@
import type { RouteLocationNormalized } from 'vue-router'
export default defineNuxtRouteMiddleware((to) => { export default defineNuxtRouteMiddleware((to) => {
if (process.server) if (process.server)
return return
@ -5,14 +7,19 @@ export default defineNuxtRouteMiddleware((to) => {
if (to.path === '/signin/callback') if (to.path === '/signin/callback')
return return
onHydrated(() => { if (isHydrated.value)
if (!currentUser.value) { return handleAuth(to)
if (to.path === '/home' && to.query['share-target'] !== undefined)
return navigateTo('/share-target') onHydrated(() => handleAuth(to))
else
return navigateTo(`/${currentServer.value}/public/local`)
}
if (to.path === '/')
return navigateTo('/home')
})
}) })
function handleAuth(to: RouteLocationNormalized) {
if (!currentUser.value) {
if (to.path === '/home' && to.query['share-target'] !== undefined)
return navigateTo('/share-target')
else
return navigateTo(`/${currentServer.value}/public/local`)
}
if (to.path === '/')
return navigateTo('/home')
}