From 62ac655922265bcc61edb42ff238aaca2cfba4c8 Mon Sep 17 00:00:00 2001 From: Draconizations Date: Mon, 30 May 2022 13:02:04 +0200 Subject: [PATCH] feat(dashboard): go to home when loading dash page while not logged in --- dashboard/src/pages/Group.svelte | 7 ++++++- dashboard/src/pages/Member.svelte | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dashboard/src/pages/Group.svelte b/dashboard/src/pages/Group.svelte index 5f74b71c..46c8d5d3 100644 --- a/dashboard/src/pages/Group.svelte +++ b/dashboard/src/pages/Group.svelte @@ -2,7 +2,7 @@ import { Container, Row, Col, Alert, Spinner, Card, CardHeader, CardBody, Accordion, AccordionItem, CardTitle } from "sveltestrap"; import Body from '../lib/group/Body.svelte'; import MemberBody from '../lib/member/Body.svelte'; - import { useParams, Link } from 'svelte-navigator'; + import { useParams, Link, navigate } from 'svelte-navigator'; import { onMount } from 'svelte'; import api from "../api"; import { Member, Group } from "../api/types"; @@ -39,6 +39,11 @@ $: orderedMembers = members.sort((a, b) => a.name.localeCompare(b.name)); $: slicedMembers = orderedMembers.slice(indexOfFirstItem, indexOfLastItem); + if (!isPublic && isPage) { + let user = localStorage.getItem("pk-user"); + if (!user) navigate("/"); + } + onMount(() => { fetchGroup(); }); diff --git a/dashboard/src/pages/Member.svelte b/dashboard/src/pages/Member.svelte index e6e90a10..69aba683 100644 --- a/dashboard/src/pages/Member.svelte +++ b/dashboard/src/pages/Member.svelte @@ -2,7 +2,7 @@ import { Container, Row, Col, Alert, Spinner, Card, CardHeader, CardBody, Accordion, AccordionItem, CardTitle } from "sveltestrap"; import Body from '../lib/member/Body.svelte'; import GroupBody from '../lib/group/Body.svelte'; - import { useParams, Link } from 'svelte-navigator'; + import { useParams, Link, navigate } from 'svelte-navigator'; import { onMount } from 'svelte'; import api from "../api"; import { Member, Group } from "../api/types"; @@ -40,6 +40,11 @@ $: orderedGroups = groups.sort((a, b) => a.name.localeCompare(b.name)); $: slicedGroups = orderedGroups.slice(indexOfFirstItem, indexOfLastItem); + if (!isPublic && isPage) { + let user = localStorage.getItem("pk-user"); + if (!user) navigate("/"); + } + onMount(() => { fetchMember(); });