diff --git a/apps/frontend/src/composables/auth.js b/apps/frontend/src/composables/auth.js index 736756d7c2..e69d6a4d52 100644 --- a/apps/frontend/src/composables/auth.js +++ b/apps/frontend/src/composables/auth.js @@ -104,13 +104,28 @@ export const initAuth = async (oldToken = null) => { return auth } +export const getSignInRedirectPath = (route) => { + const fullPath = route.fullPath + if (fullPath === '/auth' || fullPath.startsWith('/auth/')) { + return '/dashboard' + } + return fullPath +} + +export const getSignInRouteObj = (route, redirectOverride) => ({ + path: '/auth/sign-in', + query: { + redirect: redirectOverride ?? getSignInRedirectPath(route), + }, +}) + export const getAuthUrl = (provider, redirect = '/dashboard') => { const config = useRuntimeConfig() const route = useNativeRoute() const fullURL = route.query.launcher ? getLauncherRedirectUrl(route) - : `${config.public.siteUrl}/auth/sign-in?redirect=${redirect}` + : `${config.public.siteUrl}/auth/sign-in?redirect=${encodeURIComponent(redirect)}` return `${config.public.apiBaseUrl}auth/init?provider=${provider}&url=${encodeURIComponent(fullURL)}` } diff --git a/apps/frontend/src/layouts/default.vue b/apps/frontend/src/layouts/default.vue index 6ef59f08c5..99c8b33a81 100644 --- a/apps/frontend/src/layouts/default.vue +++ b/apps/frontend/src/layouts/default.vue @@ -501,7 +501,7 @@