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
This commit is contained in:
2026-04-12 20:29:39 +08:00
parent 377a9617be
commit 07e5d42005
23 changed files with 294 additions and 267 deletions

View File

@@ -1,3 +1,5 @@
import { needsUserOnboarding } from '~~/shared/auth'
export default defineNuxtRouteMiddleware(async (to) => {
const auth = useAuth()
await auth.fetchSession()
@@ -6,7 +8,7 @@ export default defineNuxtRouteMiddleware(async (to) => {
return navigateTo('/login')
}
if (to.path !== '/security' && auth.needsOnboarding.value) {
if (to.path !== '/security' && needsUserOnboarding(auth.user.value)) {
return navigateTo('/security')
}
})