export default defineNuxtRouteMiddleware((to) => {
  if (to.meta.public) return

  const { $pinia } = useNuxtApp()
  if (import.meta.client) {
    const userStore = useUserStore($pinia)

    console.log('currRole', userStore.userRole)
    console.log('isAuth', userStore.isAuthenticated)
    if (!userStore.isAuthenticated) {
      return navigateTo('/401')
    }
  }
})
