From 24ed4204fafabeeb3689447a1c170314df209cca Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 29 Oct 2024 11:35:51 +0530 Subject: [PATCH 1/2] Fixed: issue in redirection using back button from the app to launchpad Replaced the push method with replace method when making the redirection from dxp login page to app home/redirectRoute, this will not store the login page in the browsers history --- src/components/DxpLogin.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/DxpLogin.vue b/src/components/DxpLogin.vue index a56e635..16257ae 100644 --- a/src/components/DxpLogin.vue +++ b/src/components/DxpLogin.vue @@ -105,8 +105,7 @@ async function handleUserFlow(token: string, oms: string, expirationTime: string notificationContext.addNotification, ) } - - redirectRoute ? router.push(redirectRoute) : router.push('/') + router.replace(redirectRoute ? redirectRoute : '/') } catch (err: any) { console.error(err) error.value.message = 'Please contact the administrator.' From 43ff78a057953dfe75a9de236291ab3740e8cfab Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 29 Oct 2024 14:50:01 +0530 Subject: [PATCH 2/2] Improved: used replace method in place of href for logout cases as well --- src/components/DxpLogin.vue | 6 +++--- src/components/DxpUserProfile.vue | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/DxpLogin.vue b/src/components/DxpLogin.vue index 16257ae..e641491 100644 --- a/src/components/DxpLogin.vue +++ b/src/components/DxpLogin.vue @@ -50,7 +50,7 @@ const error = ref({ onMounted(async () => { if (!Object.keys(route.query).length) { - window.location.href = context.appLoginUrl + window.location.replace(context.appLoginUrl) return } @@ -73,7 +73,7 @@ async function handleUserFlow(token: string, oms: string, expirationTime: string console.error('User token has expired, redirecting to launchpad.') error.value.message = 'User token has expired, redirecting to launchpad.' const redirectUrl = window.location.origin + '/login' // current app URL - window.location.href = `${context.appLoginUrl}?isLoggedOut=true&redirectUrl=${redirectUrl}` + window.location.replace(`${context.appLoginUrl}?isLoggedOut=true&redirectUrl=${redirectUrl}`) return } @@ -116,7 +116,7 @@ async function handleUserFlow(token: string, oms: string, expirationTime: string } function goToLaunchpad() { - window.location.href = `${process.env.VUE_APP_LOGIN_URL}` + window.location.replace(process.env.VUE_APP_LOGIN_URL) } diff --git a/src/components/DxpUserProfile.vue b/src/components/DxpUserProfile.vue index 087ab07..acc9cb2 100644 --- a/src/components/DxpUserProfile.vue +++ b/src/components/DxpUserProfile.vue @@ -65,7 +65,7 @@ const logout = () => { appState.dispatch('user/logout').then(() => { const redirectUrl = window.location.origin + '/login' - window.location.href = `${appLoginUrl}?isLoggedOut=true&redirectUrl=${redirectUrl}` + window.location.replace(`${appLoginUrl}?isLoggedOut=true&redirectUrl=${redirectUrl}`) }) }