From 0dc7d39b5c130c24aafec5fabb2c45cfb98e7c8b Mon Sep 17 00:00:00 2001 From: Sumit Bhanushali Date: Wed, 24 Apr 2024 13:46:30 +0530 Subject: [PATCH] fix: redirect to landing when logged in, show invalid page when wrong path --- desk/src/components/icons/TicketIcon.vue | 16 ++++++++++++++++ desk/src/pages/InvalidPage.vue | 17 +++++++++++++++++ desk/src/router/index.js | 17 +++++++++++++++-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 desk/src/components/icons/TicketIcon.vue create mode 100644 desk/src/pages/InvalidPage.vue diff --git a/desk/src/components/icons/TicketIcon.vue b/desk/src/components/icons/TicketIcon.vue new file mode 100644 index 000000000..f8c333af7 --- /dev/null +++ b/desk/src/components/icons/TicketIcon.vue @@ -0,0 +1,16 @@ + diff --git a/desk/src/pages/InvalidPage.vue b/desk/src/pages/InvalidPage.vue new file mode 100644 index 000000000..8ab5657be --- /dev/null +++ b/desk/src/pages/InvalidPage.vue @@ -0,0 +1,17 @@ + + + diff --git a/desk/src/router/index.js b/desk/src/router/index.js index d647dd3b9..bb51e1a43 100644 --- a/desk/src/router/index.js +++ b/desk/src/router/index.js @@ -55,6 +55,11 @@ const routes = [ name: ONBOARDING_PAGE, component: () => import("@/pages/onboarding/SimpleOnboarding.vue"), }, + { + path: "/:invalidpath", + name: "Invalid Page", + component: () => import("@/pages/InvalidPage.vue"), + }, { path: "", name: "AgentRoot", @@ -197,8 +202,16 @@ router.beforeEach(async (to) => { await authStore.init(); await usersStore.init(); - if ((to.meta.agent && !authStore.hasDeskAccess) || isAuthRoute) { - router.replace({ name: WEBSITE_ROOT }); + if (isAuthRoute && authStore.isLoggedIn) { + if (authStore.isAgent) { + router.replace({ name: AGENT_PORTAL_LANDING }); + } else { + router.replace({ name: CUSTOMER_PORTAL_LANDING }); + } + } else if (!isAuthRoute && !authStore.isLoggedIn) { + router.replace({ name: "Login" }); + } else if (to.matched.length === 0) { + router.replace({ name: "Invalid Page" }); } } catch { if (!isAuthRoute) {