feat(fullstack): Set user roles per orga, scope notification to orga and role, add orga and role to JWT
This commit is contained in:
@@ -93,7 +93,7 @@ export function useAuth() {
|
||||
redirectGuestTo: '/login'
|
||||
})
|
||||
|
||||
async function fetchSession() {
|
||||
async function fetchSession(targetPath?: string) {
|
||||
if (sessionFetching.value) {
|
||||
console.log('already fetching session')
|
||||
return
|
||||
@@ -109,7 +109,7 @@ export function useAuth() {
|
||||
sessionFetching.value = false
|
||||
|
||||
// Only fetch JWT and organizations if we have a session and not on public routes
|
||||
if (session.value && !isPublicRoute()) {
|
||||
if (session.value && !isPublicPath(targetPath)) {
|
||||
await fetchJwtAndOrganizations()
|
||||
}
|
||||
|
||||
@@ -160,10 +160,10 @@ export function useAuth() {
|
||||
})
|
||||
}
|
||||
|
||||
function isPublicRoute(routeToCheck?: RouteLocationNormalizedLoaded) {
|
||||
const finalRoute = routeToCheck ?? route
|
||||
function isPublicPath(path?: string) {
|
||||
const finalPath = path ?? route.path
|
||||
const publicRoutes = ['/login', '/signup', '/accept-invitation']
|
||||
return publicRoutes.some((path) => finalRoute.path.startsWith(path))
|
||||
return publicRoutes.some((path) => finalPath.startsWith(path))
|
||||
}
|
||||
|
||||
async function signOut({ redirectTo }: { redirectTo?: RouteLocationRaw } = {}) {
|
||||
@@ -195,7 +195,7 @@ export function useAuth() {
|
||||
fetchSession,
|
||||
client,
|
||||
jwt,
|
||||
isPublicRoute,
|
||||
isPublicPath,
|
||||
activeMember
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user