export default defineNuxtRouteMiddleware(async () => {
  const auth = useAuthStore()

  if (!auth.checked) {
    await auth.ensureSession()
  }

  const isSuperAdmin = auth.user?.roles?.includes('ROLE_SUPER_ADMIN')
  if (!isSuperAdmin) {
    return navigateTo('/')
  }
})
