From 7a5ba5ea4aec0704070cfe8d63ba504a07d88cc6 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 1 Oct 2022 16:44:31 +0800 Subject: feat: Functionality complete public sites --- apps/kit/src/routes/(main)/(public)/+layout.svelte | 18 +++++ .../(main)/(public)/reset-password/+page.svelte | 16 ++--- .../(public)/reset-password/[id]/+page.svelte | 79 ++++++++++++---------- .../routes/(main)/(public)/sign-in/+page.svelte | 79 ++++++++++++++++------ .../routes/(main)/(public)/sign-up/+page.svelte | 61 +++++++++++++---- 5 files changed, 177 insertions(+), 76 deletions(-) create mode 100644 apps/kit/src/routes/(main)/(public)/+layout.svelte (limited to 'apps/kit/src/routes/(main)/(public)') diff --git a/apps/kit/src/routes/(main)/(public)/+layout.svelte b/apps/kit/src/routes/(main)/(public)/+layout.svelte new file mode 100644 index 0000000..69c29c5 --- /dev/null +++ b/apps/kit/src/routes/(main)/(public)/+layout.svelte @@ -0,0 +1,18 @@ + + + + diff --git a/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte b/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte index 9ee4a83..aa26892 100644 --- a/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte +++ b/apps/kit/src/routes/(main)/(public)/reset-password/+page.svelte @@ -37,16 +37,14 @@
-
-

- {$LL.requestAPasswordReset()} +
+

+ {$LL.resetPasswordPage.requestAPasswordReset()}

-

+

{$LL.or().toLowerCase()} - {$LL.signIntoYourAccount()} + {$LL.signIntoYourAccount().toLowerCase()}

@@ -64,7 +62,7 @@ @@ -77,7 +75,7 @@ bind:value={formData.email} label={$LL.emailAddress()} /> -

diff --git a/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte b/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte index 7b46d2d..562d902 100644 --- a/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte +++ b/apps/kit/src/routes/(main)/(public)/reset-password/[id]/+page.svelte @@ -9,6 +9,7 @@ import type { PageServerData } from "./$types"; import type { ErrorResult } from "$lib/models/ErrorResult"; import { goto } from "$app/navigation"; + import { Message, messageQueryKey } from "../../sign-in/+page.svelte"; export let data: PageServerData; @@ -16,18 +17,15 @@ newPassword: "", }; - $: showErrorAlert = - (errorData?.text.length ?? 0 + errorData?.title.length ?? 0) > 0 && - !showSuccessAlert; - const errorData = { text: "", title: "", } as ErrorResult; + let errorState: undefined | "expired" | "404" | "unknown"; + let finishedPreliminaryLoading = false; let loading = false; - let showSuccessAlert = false; let canSubmit = true; async function submitFormAsync() { @@ -38,39 +36,48 @@ formData.newPassword ); if (request.ok) { - goto("/sign-in?m=1"); + goto( + "/sign-in?" + + messageQueryKey + + "=" + + Message.AFTER_PASSWORD_RESET + ); } loading = false; } onMount(async () => { + errorState = undefined; const isValidRequest = await check_forgot_password_request( data.resetRequestId ); - if (!isValidRequest.ok) { - errorData.text = isValidRequest.data?.text ?? $LL.tryAgainSoon(); - errorData.title = - isValidRequest.data?.title ?? $LL.unexpectedError(); + if (!isValidRequest.ok && isValidRequest.status !== 404) { + errorState = "unknown"; + canSubmit = false; + } + if (isValidRequest.status === 404) { + errorState = "404"; + canSubmit = false; + } + if (isValidRequest.ok && isValidRequest.data !== true) { + errorState = "expired"; canSubmit = false; } - if (isValidRequest.status === 404) goto("/reset-password"); finishedPreliminaryLoading = true; });
{#if finishedPreliminaryLoading} -
-

- {$LL.requestAPasswordReset()} +
+

+ {$LL.resetPasswordPage.setANewPassword()}

-

+

{$LL.or().toLowerCase()} - {$LL.signIntoYourAccount()} + {$LL.signIntoYourAccount().toLowerCase()}

@@ -81,21 +88,24 @@ class="space-y-6" on:submit|preventDefault={submitFormAsync} > - - - + {#if errorState === "404"} + + {:else if errorState === "expired"} + + {:else if errorState === "unknown"} + + {/if} +

diff --git a/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte b/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte index 8b89190..0dfa41a 100644 --- a/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte +++ b/apps/kit/src/routes/(main)/(public)/sign-up/+page.svelte @@ -1,29 +1,62 @@ -
-
-

- {$LL.createYourNewAccount()} +
+

+ {$LL.signUpPage.createYourNewAccount()}

-

+

{$LL.or().toLowerCase()} - {$LL.signIntoYourAccount()} + + {$LL.signIntoYourAccount().toLowerCase()} +

-
+ + -
-- cgit v1.3