Move files in preparation for monorepo migration

This commit is contained in:
Jai A
2024-07-03 11:13:51 -07:00
parent b6618f81f8
commit ff946b4f2f
344 changed files with 0 additions and 32 deletions

View File

@@ -0,0 +1,35 @@
const whitelistedParams = ['flow', 'error']
export default defineNuxtRouteMiddleware(async (_to, from) => {
const config = useRuntimeConfig()
const auth = await useAuth()
if (!auth.value.user) {
const fullPath = from.fullPath
const url = new URL(fullPath, config.public.apiBaseUrl)
const extractedParams = whitelistedParams.reduce((acc, param) => {
if (url.searchParams.has(param)) {
acc[param] = url.searchParams.get(param)
url.searchParams.delete(param)
}
return acc
}, {})
const redirectPath = encodeURIComponent(url.pathname + url.search)
return await navigateTo(
{
path: '/auth/sign-in',
query: {
redirect: redirectPath,
...extractedParams,
},
},
{
replace: true,
}
)
}
})