feat(fullstack): Set user roles per orga, scope notification to orga and role, add orga and role to JWT
This commit is contained in:
@@ -38,7 +38,7 @@ export default defineNuxtRouteMiddleware(async (to: RouteLocationNormalized) =>
|
||||
console.log('[1] Auth middleware disabled for this route:', to.path)
|
||||
return
|
||||
}
|
||||
const { loggedIn, options, fetchSession, isPublicRoute } = useAuth()
|
||||
const { loggedIn, options, fetchSession, isPublicPath } = useAuth()
|
||||
const { only, redirectUserTo, redirectGuestTo } = defu(to.meta?.auth, options)
|
||||
|
||||
// 2. If guest mode, redirect if authenticated
|
||||
@@ -55,7 +55,7 @@ export default defineNuxtRouteMiddleware(async (to: RouteLocationNormalized) =>
|
||||
if (import.meta.client) {
|
||||
console.log('[3] Client-side navigation, fetching session')
|
||||
try {
|
||||
await fetchSession()
|
||||
await fetchSession(to.path)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
@@ -63,7 +63,7 @@ export default defineNuxtRouteMiddleware(async (to: RouteLocationNormalized) =>
|
||||
|
||||
// 4. If not authenticated, redirect to home or guest route
|
||||
if (!loggedIn.value) {
|
||||
if (isPublicRoute(to)) {
|
||||
if (isPublicPath(to.path)) {
|
||||
console.log('[4] Not authenticated, but route is public:', to.path)
|
||||
// Continue navigating to the public route
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user