Skip to content

Commit 0dc7d39

Browse files
fix: redirect to landing when logged in, show invalid page when wrong path
1 parent 3b034a0 commit 0dc7d39

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<svg
3+
width="16"
4+
height="16"
5+
viewBox="0 0 16 16"
6+
fill="none"
7+
xmlns="http://www.w3.org/2000/svg"
8+
>
9+
<path
10+
fill-rule="evenodd"
11+
clip-rule="evenodd"
12+
d="M1.99756 4.12305C1.99756 3.8469 2.22142 3.62305 2.49756 3.62305H5V4.5875C5 4.86364 5.22386 5.0875 5.5 5.0875C5.77614 5.0875 6 4.86364 6 4.5875V3.62305L13.5023 3.62305C13.7784 3.62305 14.0023 3.84691 14.0023 4.12305V5.53459C12.9897 5.91326 12.2683 6.88902 12.2683 8.03388C12.2683 9.17875 12.9897 10.1545 14.0023 10.5332V11.8766C14.0023 12.1527 13.7784 12.3766 13.5023 12.3766H6V11.4125C6 11.1364 5.77614 10.9125 5.5 10.9125C5.22386 10.9125 5 11.1364 5 11.4125V12.3766H2.49756C2.22142 12.3766 1.99756 12.1527 1.99756 11.8766V10.5332C3.01017 10.1545 3.73152 9.17875 3.73152 8.03388C3.73152 6.88816 3.01009 5.91306 1.99756 5.53456L1.99756 4.12305ZM2.49756 2.62305C1.66913 2.62305 0.997559 3.29462 0.997559 4.12305L0.997559 5.90978C0.997559 6.14752 1.16496 6.35238 1.39793 6.39975C2.15906 6.55451 2.73152 7.22751 2.73152 8.03388C2.73152 8.83951 2.15894 9.51328 1.39793 9.66802C1.16496 9.71539 0.997559 9.92025 0.997559 10.158L0.997559 11.8766C0.997559 12.705 1.66913 13.3766 2.49756 13.3766H13.5023C14.3307 13.3766 15.0023 12.705 15.0023 11.8766V10.158C15.0023 9.92025 14.8349 9.71539 14.6019 9.66802C13.8409 9.51328 13.2683 8.83951 13.2683 8.03388C13.2683 7.22826 13.8409 6.55449 14.6019 6.39975C14.8349 6.35238 15.0023 6.14752 15.0023 5.90978V4.12305C15.0023 3.29462 14.3307 2.62305 13.5023 2.62305L2.49756 2.62305ZM6 6.5375C6 6.26136 5.77614 6.0375 5.5 6.0375C5.22386 6.0375 5 6.26136 5 6.5375V9.4625C5 9.73864 5.22386 9.9625 5.5 9.9625C5.77614 9.9625 6 9.73864 6 9.4625V6.5375Z"
13+
fill="currentColor"
14+
/>
15+
</svg>
16+
</template>

desk/src/pages/InvalidPage.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<div
3+
class="grid h-full place-items-center px-4 py-20 text-center text-lg text-gray-600"
4+
>
5+
<div class="space-y-2">
6+
<div>Invalid page or not permitted to access</div>
7+
<Button :route="{ name: 'TicketsAgent' }">
8+
<template #prefix><TicketIcon class="w-4" /></template>
9+
Tickets
10+
</Button>
11+
</div>
12+
</div>
13+
</template>
14+
15+
<script setup>
16+
import TicketIcon from "@/components/icons/TicketIcon.vue";
17+
</script>

desk/src/router/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ const routes = [
5555
name: ONBOARDING_PAGE,
5656
component: () => import("@/pages/onboarding/SimpleOnboarding.vue"),
5757
},
58+
{
59+
path: "/:invalidpath",
60+
name: "Invalid Page",
61+
component: () => import("@/pages/InvalidPage.vue"),
62+
},
5863
{
5964
path: "",
6065
name: "AgentRoot",
@@ -197,8 +202,16 @@ router.beforeEach(async (to) => {
197202
await authStore.init();
198203
await usersStore.init();
199204

200-
if ((to.meta.agent && !authStore.hasDeskAccess) || isAuthRoute) {
201-
router.replace({ name: WEBSITE_ROOT });
205+
if (isAuthRoute && authStore.isLoggedIn) {
206+
if (authStore.isAgent) {
207+
router.replace({ name: AGENT_PORTAL_LANDING });
208+
} else {
209+
router.replace({ name: CUSTOMER_PORTAL_LANDING });
210+
}
211+
} else if (!isAuthRoute && !authStore.isLoggedIn) {
212+
router.replace({ name: "Login" });
213+
} else if (to.matched.length === 0) {
214+
router.replace({ name: "Invalid Page" });
202215
}
203216
} catch {
204217
if (!isAuthRoute) {

0 commit comments

Comments
 (0)