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=1737247214; bh=s0v9+6BHJopa6EPY9au4mhNgkoLURZhyEe/zS37nTBc=; 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=YEtDUl4pnfl9aT0Ztykzgy+ojb4YrdK1/YRg4Tz66EC7Vobr4dt5SMtjDbIdM/xVC Gj6m3mTGMrCRsm9P4JTdDno7vVHOB9t2E113G8hc46zzCP0cU5LP9iCN0JYd0RO6Dh Gg5Wpb3Ea2Ht2ToScs0TKE33SYr+OwRvNrO6MFaVlN6xgnsZpK8hh9DMxn/Q4adde2 DfxCi2FimMAqA/o+ALaSQlM1Ew7YXJA/MyfFICe5p4A2JQ7euXKciF6/3SX0uZlD89 WwX1OXIvzxLpP16/QTZxcmU6lnmED3iH3r+3L08C4A8kJLuOyv6yE8WGVDV+OLXRj3 OXGTnc/Y9JVaQ== Received: from localhost.localdomain (unknown [101.128.125.239]) by server-vie001.gnuweeb.org (Postfix) with ESMTPSA id AEE0A2061C33; Sun, 19 Jan 2025 00:40:13 +0000 (UTC) From: Muhammad Rizki To: Ammar Faizi Cc: Kiizuha Kanazawa , Alviro Iskandar Setiawan , Dwiky Rizky Ananditya , GNU/Weeb Mailing List Subject: [PATCH v1 14/16] feat(routes): add login page Date: Sun, 19 Jan 2025 07:39:07 +0700 Message-ID: <20250119003911.1183-15-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 page includes login form and its page authentication handler. Signed-off-by: Kiizuha Kanazawa --- src/routes/+page.svelte | 124 +++++++++++++++++++++++++++++++++++++++- src/routes/+page.ts | 17 ++++++ 2 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 src/routes/+page.ts diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index cc88df0..46ef170 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,2 +1,122 @@ -

Welcome to SvelteKit

-

Visit svelte.dev/docs/kit to read the documentation

+ + +
+ +
+ + GNU/Weeb Mail Login + Proceed login to manager your email account + + {#if isError()} + + {$message} + + {/if} + + + + + + {#snippet children({ props })} + Username or Email + + + {/snippet} + + + + + + {#snippet children({ props })} + Password + + + {/snippet} + + + + + + + +
+
+
diff --git a/src/routes/+page.ts b/src/routes/+page.ts new file mode 100644 index 0000000..99ac97a --- /dev/null +++ b/src/routes/+page.ts @@ -0,0 +1,17 @@ +import { loginSchema } from "$lib/schemas/login"; +import { superValidate } from "sveltekit-superforms"; +import { zod } from "sveltekit-superforms/adapters"; +import type { PageLoad } from "./$types"; +import { useAuth } from "$lib/hooks/auth.svelte"; +import { redirect } from "@sveltejs/kit"; + +export const load: PageLoad = async () => { + const auth = useAuth(); + + if (auth.isValid()) return redirect(307, "/home"); + + const data = { email: "", password: "" }; + const form = await superValidate(data, zod(loginSchema)); + + return { form }; +}; -- Muhammad Rizki