feat(front) : modular nuxt config with app/ shell dirs and modules/* layer auto-detection
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export default defineNuxtRouteMiddleware(() => {
|
||||
const auth = useAuthStore()
|
||||
|
||||
if (!auth.isAuthenticated || !auth.user?.roles?.includes('ROLE_ADMIN')) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
const auth = useAuthStore()
|
||||
const isLogin = to.path === '/login'
|
||||
|
||||
if (!auth.checked) {
|
||||
await auth.ensureSession()
|
||||
}
|
||||
|
||||
if (!isLogin && !auth.isAuthenticated) {
|
||||
return navigateTo('/login')
|
||||
}
|
||||
|
||||
if (isLogin && auth.isAuthenticated) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
export default defineNuxtRouteMiddleware(() => {
|
||||
const auth = useAuthStore()
|
||||
|
||||
// "Mes absences" is reserved for users flagged as employees (subject to the
|
||||
// absence management). Non-employees are redirected to the home page.
|
||||
if (!auth.isAuthenticated || !auth.user?.isEmployee) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user