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