From e2a67eba9080af6eb4923c6cdd9f14ec43bca593 Mon Sep 17 00:00:00 2001 From: Andreani Jean Date: Tue, 4 Jul 2023 09:27:32 +0200 Subject: [PATCH] test new guard router --- src/router/index.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 32f58ba..ab42861 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -59,19 +59,27 @@ router.beforeEach(async (to, from, next) => { to.name === 'my-settings' || to.name === 'my-sequences' || to.name === 'sequence' + const url = `${location.protocol}//${location.host}` + const nextRoute = `${url}${to.path}` + console.log(url) + console.log(nextRoute) if (loggedRoutes) { try { const loginUrl = `/api/users/me` const isKeycloakLogout = await axios.get(loginUrl) const isSiteLogin = !!cookies.get('user_id') if (isKeycloakLogout.status >= 300 || !isSiteLogin) { - window.location.replace(getAuthRoute('/auth/login', to.path)) + window.location.replace( + `${url}auth/login?next_url=${encodeURIComponent(nextRoute)}` + ) } else { next() } } catch (e) { - window.location.replace(getAuthRoute('/auth/login', to.path)) - next() + console.log('CAAAATCH', `${url}/api/auth/login`) + window.location.replace( + `${url}/api/auth/login?next_url=${encodeURIComponent(nextRoute)}` + ) } } else next() })