Skip to content

Commit

Permalink
fix: redirect to landing when logged in, show invalid page when wrong…
Browse files Browse the repository at this point in the history
… path
  • Loading branch information
sumitbhanushali committed Apr 24, 2024
1 parent 3b034a0 commit 0dc7d39
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
16 changes: 16 additions & 0 deletions desk/src/components/icons/TicketIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
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"
fill="currentColor"
/>
</svg>
</template>
17 changes: 17 additions & 0 deletions desk/src/pages/InvalidPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<div
class="grid h-full place-items-center px-4 py-20 text-center text-lg text-gray-600"
>
<div class="space-y-2">
<div>Invalid page or not permitted to access</div>
<Button :route="{ name: 'TicketsAgent' }">
<template #prefix><TicketIcon class="w-4" /></template>
Tickets
</Button>
</div>
</div>
</template>

<script setup>
import TicketIcon from "@/components/icons/TicketIcon.vue";
</script>
17 changes: 15 additions & 2 deletions desk/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0dc7d39

Please sign in to comment.