Files
shiftcraft/app/middleware/00.fetchUser.global.ts
2026-04-17 23:26:01 +00:00

11 lines
301 B
TypeScript

/**
* 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()
}
})