/**
 * Middleware to refresh the authenticated user if possible
 * Executed on all route changes
 */
export default defineNuxtRouteMiddleware(async () => {
  if (!useUser().isAuthenticated || useUser().user === null) {
    // Attempt to refresh the auth store
    await useUser().authRefresh()
  }
})
