Auth-Middleware aus Cookie initialisieren
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
export default defineNuxtRouteMiddleware(async (to, from) => {
|
export default defineNuxtRouteMiddleware(async (to, from) => {
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
const isPortalUser = Boolean(auth.profile?.customer_for_portal)
|
const token = useCookie<string | null>("token", { path: "/" }).value
|
||||||
|
|
||||||
// DEBUG: Was sieht die Middleware wirklich?
|
// DEBUG: Was sieht die Middleware wirklich?
|
||||||
console.log("🔒 Middleware Check auf:", to.path)
|
console.log("🔒 Middleware Check auf:", to.path)
|
||||||
@@ -13,6 +13,13 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!auth.user && token && process.client) {
|
||||||
|
console.log("🔄 Auth-Bootstrap aus Cookie")
|
||||||
|
await auth.initStore()
|
||||||
|
}
|
||||||
|
|
||||||
|
const isPortalUser = Boolean(auth.profile?.customer_for_portal)
|
||||||
|
|
||||||
if (auth.loading) {
|
if (auth.loading) {
|
||||||
console.log("⏳ Auth lädt noch...")
|
console.log("⏳ Auth lädt noch...")
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user