a18e1f575f
- drop ClientPortal module, ClientTicket entity, ROLE_CLIENT and all couplings (Task, TaskDocument, User, Notification) back to an internal-only model - migration drops client_ticket / user_allowed_projects / related FK columns and removes leftover external client accounts (would otherwise be promoted to ROLE_USER) - remove client-portal frontend module, admin tickets tab, user portal section, portal nav item and portal/clientTicket i18n keys - fix directory nav icon (invalid mdi:contact-multiple-outline -> mdi:card-account-details-outline) - add 'make sync-permissions' target, wire it into install/db-reset and the prod deploy script
31 lines
887 B
TypeScript
31 lines
887 B
TypeScript
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('/')
|
|
}
|
|
|
|
const { loaded: sidebarLoaded, loadSidebar, resetSidebar } = useSidebar()
|
|
const { loaded: modulesLoaded, loadModules, resetModules } = useModules()
|
|
|
|
if (auth.isAuthenticated) {
|
|
await Promise.all([
|
|
sidebarLoaded.value ? Promise.resolve() : loadSidebar(),
|
|
modulesLoaded.value ? Promise.resolve() : loadModules(),
|
|
])
|
|
} else {
|
|
// Logout / session expirée : purge l'état partagé pour le prochain login.
|
|
resetSidebar()
|
|
resetModules()
|
|
}
|
|
})
|