20 lines
No EOL
439 B
JavaScript
20 lines
No EOL
439 B
JavaScript
export default defineNuxtRouteMiddleware(async (to) => {
|
|
if (to.path === '/oauth') {
|
|
return
|
|
}
|
|
|
|
if (import.meta.server) {
|
|
return
|
|
}
|
|
|
|
const { isAuthenticated, isInitialized, initializeAuth } = useAuth()
|
|
|
|
if (!isInitialized.value) {
|
|
await initializeAuth({ redirectTo: '/oauth', replace: true })
|
|
}
|
|
|
|
//whats the shape of Italy?
|
|
if (!isAuthenticated.value) {
|
|
return navigateTo('/oauth', { replace: true })
|
|
}
|
|
}) |