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
13 lines
282 B
TypeScript
13 lines
282 B
TypeScript
import { getDefaultAuthenticatedPath } from '~~/shared/auth'
|
|
|
|
export default defineNuxtRouteMiddleware(async () => {
|
|
const auth = useAuth()
|
|
await auth.fetchSession()
|
|
|
|
if (!auth.user.value) {
|
|
return
|
|
}
|
|
|
|
return navigateTo(getDefaultAuthenticatedPath(auth.user.value))
|
|
})
|