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:
@@ -1,3 +1,5 @@
|
||||
import { needsUserOnboarding } from '~~/shared/auth'
|
||||
|
||||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const auth = useAuth()
|
||||
await auth.fetchSession()
|
||||
@@ -6,7 +8,7 @@ export default defineNuxtRouteMiddleware(async () => {
|
||||
return navigateTo('/login')
|
||||
}
|
||||
|
||||
if (auth.needsOnboarding.value) {
|
||||
if (needsUserOnboarding(auth.user.value)) {
|
||||
return navigateTo('/security')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user