diff options
Diffstat (limited to 'apps/accounts/src/app/pages/forgot.svelte')
| -rw-r--r-- | apps/accounts/src/app/pages/forgot.svelte | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/apps/accounts/src/app/pages/forgot.svelte b/apps/accounts/src/app/pages/forgot.svelte deleted file mode 100644 index f22d664..0000000 --- a/apps/accounts/src/app/pages/forgot.svelte +++ /dev/null @@ -1,99 +0,0 @@ -<script> - import {onMount} from "svelte"; - import {link} from "svelte-spa-router"; - import {create_forgot_password_request} from "$shared/lib/api/user"; - import {is_email} from "$shared/lib/helpers"; - import Alert from "$shared/components/alert.svelte"; - import Button from "$shared/components/button.svelte"; - import Layout from "./_layout.svelte"; - - let isLoading = false; - let username; - - const alert = { - title: "", - type: "", - message: "", - isVisible: false, - show(type, obj) { - alert.title = obj.title; - alert.message = obj.text; - alert.type = type; - alert.isVisible = true; - isLoading = false; - }, - hide() { - alert.isVisible = false; - alert.title = ""; - alert.message = ""; - alert.type = ""; - isLoading = false; - }, - }; - - function is_valid() { - return is_email(username); - } - - async function submit_form() { - if (isLoading) { - return; - } - if (is_valid()) { - isLoading = true; - const response = await create_forgot_password_request(username); - if (response.ok) { - alert.show("success", { - title: "Request is sent", - text: "If we find an account associated with this email address, you will receive an email with a reset link very soon.", - }); - } else { - console.error(response.data); - alert.show("error", { - title: response.data?.title ?? "An error occured", - text: response.data?.text ?? "Please try again soon", - }); - } - } - } - - onMount(() => { - document.addEventListener("DOMContentLoaded", () => { - document.getElementById("email-address").focus(); - }); - }); -</script> - -<Layout> - <form on:submit|preventDefault={submit_form} - class="margin-bottom-md max-width-xxs"> - <fieldset> - <legend class="form-legend"> - <span class="margin-bottom-xs">Send reset link</span> <br/> - <span class="text-sm">... or <a href="/login" - use:link>log in</a></span> - </legend> - <div class="margin-bottom-xs"> - <p>Provide your email address, and we'll send you a link to set your new password.</p> - </div> - <div class="margin-bottom-xxs max-width-xxs"> - <Alert visible={alert.isVisible} - title={alert.title} - message={alert.message} - type={alert.type}/> - </div> - <div class="margin-bottom-xs"> - <input type="email" - id="email-address" - placeholder="Email address" - class="form-control width-100%" - bind:value={username}/> - </div> - <div class="flex justify-end"> - <Button text="Send reset link" - type="primary" - loading={isLoading}/> - </div> - </fieldset> - </form> -</Layout> |
