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

11 lines
317 B
TypeScript

/**
* Middleware to protect routes that require authentication.
* Redirects to the login page if the user is not authenticated.
*/
export default defineNuxtRouteMiddleware(async () => {
if (!useUser().isAuthenticated) {
// If still not authenticated, redirect to login
return navigateTo('/login')
}
})