fix: keep session middleware from redirecting prematurely
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { useProfileSession } from '#imports'
|
import { useProfileSession } from '#imports'
|
||||||
|
|
||||||
export default defineNuxtRouteMiddleware(async (to) => {
|
export default defineNuxtRouteMiddleware(async (to) => {
|
||||||
const { ensureSession, activeProfile } = useProfileSession()
|
const { ensureSession, fetchCurrentProfile, activeProfile } = useProfileSession()
|
||||||
await ensureSession()
|
await ensureSession()
|
||||||
|
|
||||||
const rawPath = to?.path ?? ''
|
const rawPath = to?.path ?? ''
|
||||||
@@ -13,6 +13,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
|||||||
fullPath.startsWith('/profiles') ||
|
fullPath.startsWith('/profiles') ||
|
||||||
routeName.startsWith('profiles')
|
routeName.startsWith('profiles')
|
||||||
|
|
||||||
|
if (process.client && !activeProfile.value) {
|
||||||
|
await fetchCurrentProfile()
|
||||||
|
}
|
||||||
|
|
||||||
if (process.client && !activeProfile.value && !isProfilesRoute) {
|
if (process.client && !activeProfile.value && !isProfilesRoute) {
|
||||||
return navigateTo('/profiles')
|
return navigateTo('/profiles')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user