|
|
@ -36,6 +36,8 @@ import { useApi, useGlobal } from '#imports' |
|
|
|
export default defineNuxtRouteMiddleware(async (to, from) => { |
|
|
|
export default defineNuxtRouteMiddleware(async (to, from) => { |
|
|
|
const state = useGlobal() |
|
|
|
const state = useGlobal() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { api } = useApi() |
|
|
|
|
|
|
|
|
|
|
|
/** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */ |
|
|
|
/** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */ |
|
|
|
if (!state.signedIn && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth() |
|
|
|
if (!state.signedIn && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth() |
|
|
|
|
|
|
|
|
|
|
@ -65,6 +67,15 @@ export default defineNuxtRouteMiddleware(async (to, from) => { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return navigateTo(from.path) |
|
|
|
return navigateTo(from.path) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/** if users are accessing the projects without having enough permissions, redirect to My Projects page */ |
|
|
|
|
|
|
|
if (to.params.projectId) { |
|
|
|
|
|
|
|
const user = await api.auth.me({ project_id: to?.params?.projectId as string }) |
|
|
|
|
|
|
|
if (user?.roles?.user) { |
|
|
|
|
|
|
|
message.error("You don't have enough permission to access the project.") |
|
|
|
|
|
|
|
return navigateTo('/') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|