From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server-vie001.gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_DBL_BLOCKED_OPENDNS, URIBL_ZEN_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1737247213; bh=sln14QxD28VweUnfKj/WyJhcoUvOnvVrjqK4V+XsNS8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding:Message-ID:Date:From: Reply-To:Subject:To:Cc:In-Reply-To:References:Resent-Date: Resent-From:Resent-To:Resent-Cc:User-Agent:Content-Type: Content-Transfer-Encoding; b=HKdzpfh3SiaDvDFxBTcIhbYM6czRb2yvraTmM7j0G3YLUc29SC8T11kWUPXvw6Vrt TlAoxUl3ZA1JdJGM9itBDkN4SClLZs2JdmUFRdB7l8TY/+j/CRGTdDQA+9oljZ4o8I IG89byvEL/VmXIOKr+xQK1eNRKseSHpTLuMkzJlZbjCu5vwxyZjtlqbfW2qon4SCci 6RNj9gR6yKcRHDZDBPqxvCec1/zTOTb9s/PnWCmRnUW/UruqnA2pr++S0tUWIpUoKt I15iI20YmUuu4wRoHzZh49pL0eJLHJlg/BydxZ7PpeIb6wV5gZ1KIp2nA8NnjSglUZ 4g3XfB56Vs66A== Received: from localhost.localdomain (unknown [101.128.125.239]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id 005D52061C22; Sun, 19 Jan 2025 00:40:11 +0000 (UTC) From: Muhammad Rizki To: Ammar Faizi Cc: Kiizuha Kanazawa , Alviro Iskandar Setiawan , Dwiky Rizky Ananditya , GNU/Weeb Mailing List Subject: [PATCH v1 13/16] feat(routes): add main layout for the protected routes Date: Sun, 19 Jan 2025 07:39:06 +0700 Message-ID: <20250119003911.1183-14-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.45.2.windows.1 In-Reply-To: <20250119003911.1183-1-kiizuha@gnuweeb.org> References: <20250119003911.1183-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: From: Kiizuha Kanazawa this layout includes handle authentication check, sidebar and header. Signed-off-by: Kiizuha Kanazawa --- src/routes/(protected)/+layout.svelte | 19 +++++++++++++++++++ src/routes/(protected)/+layout.ts | 11 +++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/routes/(protected)/+layout.svelte create mode 100644 src/routes/(protected)/+layout.ts diff --git a/src/routes/(protected)/+layout.svelte b/src/routes/(protected)/+layout.svelte new file mode 100644 index 0000000..e88b3fb --- /dev/null +++ b/src/routes/(protected)/+layout.svelte @@ -0,0 +1,19 @@ + + + + + + +
+ + +
{@render children()}
+ + diff --git a/src/routes/(protected)/+layout.ts b/src/routes/(protected)/+layout.ts new file mode 100644 index 0000000..dd687a1 --- /dev/null +++ b/src/routes/(protected)/+layout.ts @@ -0,0 +1,11 @@ +import { useAuth } from "$lib/hooks/auth.svelte"; +import { redirect } from "@sveltejs/kit"; +import type { LayoutLoad } from "./$types"; + +export const load: LayoutLoad = async () => { + const auth = useAuth(); + + if (!auth.isValid()) return redirect(307, "/"); + + auth.refresh(); +}; -- Muhammad Rizki