|
|
@ -24,16 +24,15 @@ import { useApi, useGlobal } from '#imports' |
|
|
|
export default defineNuxtRouteMiddleware(async (to, from) => { |
|
|
|
export default defineNuxtRouteMiddleware(async (to, from) => { |
|
|
|
const state = useGlobal() |
|
|
|
const state = useGlobal() |
|
|
|
|
|
|
|
|
|
|
|
await tryGoogleAuth() |
|
|
|
/** if user isn't signed in and google auth is enabled, try to check if sign-in data is present */ |
|
|
|
|
|
|
|
if (!state.signedIn && state.appInfo.value.googleAuthEnabled) await tryGoogleAuth() |
|
|
|
|
|
|
|
|
|
|
|
/** if public allow */ |
|
|
|
/** if public allow all visitors */ |
|
|
|
if (to.meta.public) return |
|
|
|
if (to.meta.public) return |
|
|
|
|
|
|
|
|
|
|
|
/** if shred base allow without validating */ |
|
|
|
/** if shared base allow without validating */ |
|
|
|
if (to.params?.projectType === 'base') return |
|
|
|
if (to.params?.projectType === 'base') return |
|
|
|
|
|
|
|
|
|
|
|
if (to.meta.public) return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */ |
|
|
|
/** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */ |
|
|
|
if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !state.signedIn.value) { |
|
|
|
if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !state.signedIn.value) { |
|
|
|
return navigateTo('/signin') |
|
|
|
return navigateTo('/signin') |
|
|
|