aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(static)/forgot
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-11-26 22:35:28 -0800
committerAdam Soltys <[email protected]>2024-11-26 22:35:28 -0800
commitf99bd15fabd6d7b361794f756a69d6f05a50701f (patch)
tree9bb1b14519b34c343ad3bcd001fbd4681a53e447 /src/routes/(static)/forgot
parentf4eb6547d0db5edd0137fdefe461433500515040 (diff)
downloadcoinos-ui-f99bd15fabd6d7b361794f756a69d6f05a50701f.tar.gz
coinos-ui-f99bd15fabd6d7b361794f756a69d6f05a50701f.zip
warnings
Diffstat (limited to 'src/routes/(static)/forgot')
-rw-r--r--src/routes/(static)/forgot/+page.server.ts14
-rw-r--r--src/routes/(static)/forgot/+page.svelte66
2 files changed, 80 insertions, 0 deletions
diff --git a/src/routes/(static)/forgot/+page.server.ts b/src/routes/(static)/forgot/+page.server.ts
new file mode 100644
index 00000000..55169a5e
--- /dev/null
+++ b/src/routes/(static)/forgot/+page.server.ts
@@ -0,0 +1,14 @@
+import { fail } from "@sveltejs/kit";
+import { fd, post } from "$lib/utils";
+
+export const actions = {
+ default: async ({ request }) => {
+ try {
+ const { email } = await fd(request);
+ await post("/forgot", { email });
+ return { success: true };
+ } catch (e: any) {
+ return fail(400, { error: e.message });
+ }
+ },
+};
diff --git a/src/routes/(static)/forgot/+page.svelte b/src/routes/(static)/forgot/+page.svelte
new file mode 100644
index 00000000..45180543
--- /dev/null
+++ b/src/routes/(static)/forgot/+page.svelte
@@ -0,0 +1,66 @@
+<script>
+ import { focus } from "$lib/utils";
+ import { enhance } from "$app/forms";
+ import { t } from "$lib/translations";
+ import Icon from "$comp/Icon.svelte";
+ import Spinner from "$comp/Spinner.svelte";
+ import { fly } from "svelte/transition";
+
+ let { form } = $props();
+ let email = $state();
+ let loading;
+</script>
+
+<div
+ class="mx-auto md:shadow-xl rounded-3xl max-w-xl w-full md:w-[480px] md:p-8 mb-20 space-y-5"
+>
+ <h1 class="text-2xl font-bold text-center">{$t("login.reset")}</h1>
+
+ {#if form?.error}
+ <div class="text-red-600 text-center" in:fly>
+ {form.error}
+ </div>
+ {/if}
+
+ {#if form?.success}
+ <div class="text-secondary">
+ {$t("login.resetSent")}
+ </div>
+
+ <div class="flex w-full">
+ <a href="/login" class="btn">
+ {$t("login.continue")}
+ </a>
+ </div>
+ {:else}
+ <form class="space-y-5" method="POST" use:enhance>
+ <div>
+ <input
+ placeholder={$t("login.email")}
+ name="email"
+ type="text"
+ required
+ class="bg-primary"
+ bind:value={email}
+ use:focus
+ autocapitalize="none"
+ />
+ </div>
+
+ <div class="text-secondary">
+ {$t("login.resetDesc")}
+ <a href="mailto:[email protected]" class="font-bold"
+ >
+ </div>
+
+ <button type="submit" class="btn" disabled={loading}>
+ {#if loading}
+ <Spinner />
+ {:else}
+ {$t("login.submit")}
+ {/if}
+ </button>
+ </form>
+ {/if}
+</div>