From 942143ddc73b62507ae6c003c36cd512838de725 Mon Sep 17 00:00:00 2001 From: ReLoia Date: Tue, 16 Jun 2026 18:30:26 +0200 Subject: [PATCH] refactor(auth): centralize role checks into utility Removed direct user role string checks and replaced with type-safe utils. --- app/components/Header.vue | 2 +- app/middleware/auth.ts | 15 ++-------- app/pages/admin/users.vue | 2 +- app/pages/dashboard/index.vue | 17 +++++------- app/pages/operator/reports/[id].vue | 6 +++- app/pages/profile.vue | 2 +- app/utils/roles.ts | 43 +++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 app/utils/roles.ts diff --git a/app/components/Header.vue b/app/components/Header.vue index 7db4408..89fb08d 100644 --- a/app/components/Header.vue +++ b/app/components/Header.vue @@ -34,7 +34,7 @@ const navLinks = [ ] const { isAuthenticated, user, logout } = useAuth() -const panelLabel = computed(() => user.value?.role?.toUpperCase() === 'ADMIN' ? 'Pannello' : 'Dashboard') +const panelLabel = computed(() => isAdmin(user.value?.role) ? 'Pannello' : 'Dashboard')