Files
xiaomai 07e5d42005 refactor: centralize validation, error handling, and formatting logic
Extract shared auth logic and validation rules to shared/auth.ts
Introduce utility functions for HTTP errors and user input parsing
Standardize error messages and date formatting across the app
2026-04-12 20:29:39 +08:00

15 lines
343 B
TypeScript

import { needsUserOnboarding } from '~~/shared/auth'
export default defineNuxtRouteMiddleware(async (to) => {
const auth = useAuth()
await auth.fetchSession()
if (!auth.user.value) {
return navigateTo('/login')
}
if (to.path !== '/security' && needsUserOnboarding(auth.user.value)) {
return navigateTo('/security')
}
})