aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/routes/(main)/(public)/reset-password
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-10-09 18:38:10 +0200
committerivarlovlie <git@ivarlovlie.no>2022-10-09 18:38:10 +0200
commitc0746289e8ff1c4509ea544469333baf116dbeb8 (patch)
tree1f5677342c678bf063ceb64015cdbc1d034cbcd8 /code/app/src/routes/(main)/(public)/reset-password
parent1bb31b298cab4552446aca9957f9592a34b2134f (diff)
downloadgreatoffice-c0746289e8ff1c4509ea544469333baf116dbeb8.tar.xz
greatoffice-c0746289e8ff1c4509ea544469333baf116dbeb8.zip
refactor: Update imports and clean up
Diffstat (limited to 'code/app/src/routes/(main)/(public)/reset-password')
-rw-r--r--code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js11
-rw-r--r--code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js.map1
-rw-r--r--code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte47
3 files changed, 10 insertions, 49 deletions
diff --git a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js
deleted file mode 100644
index 1c7fa30..0000000
--- a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { is_guid } from '$lib/helpers';
-import { redirect } from '@sveltejs/kit';
-export const load = async ({ params }) => {
- const resetRequestId = params.id ?? "";
- if (!is_guid(resetRequestId))
- throw redirect(302, "/reset-password");
- return {
- resetRequestId
- };
-};
-//# sourceMappingURL=+page.server.js.map \ No newline at end of file
diff --git a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js.map b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js.map
deleted file mode 100644
index 52fb93b..0000000
--- a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.server.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"file":"+page.server.js","sourceRoot":"","sources":["+page.server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,CAAC,MAAM,IAAI,GAAmB,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACrD,MAAM,cAAc,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAAE,MAAM,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IACrE,OAAO;QACH,cAAc;KACjB,CAAC;AACN,CAAC,CAAC"} \ No newline at end of file
diff --git a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte
index 562d902..c5044b5 100644
--- a/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte
+++ b/code/app/src/routes/(main)/(public)/reset-password/[id]/+page.svelte
@@ -1,15 +1,12 @@
<script lang="ts">
- import {
- check_forgot_password_request,
- fulfill_forgot_password_request,
- } from "$lib/api/user";
+ import { check_forgot_password_request, fulfill_forgot_password_request } from "$lib/api/user";
import { onMount } from "svelte";
import LL from "$lib/i18n/i18n-svelte";
import { Alert, Input, Button } from "$lib/components";
import type { PageServerData } from "./$types";
- import type { ErrorResult } from "$lib/models/ErrorResult";
+ import type { ErrorResult } from "$lib/models/internal/ErrorResult";
import { goto } from "$app/navigation";
- import { Message, messageQueryKey } from "../../sign-in/+page.svelte";
+ import { Message, messageQueryKey } from "$routes/(main)/(public)/sign-in";
export let data: PageServerData;
@@ -31,17 +28,9 @@
async function submitFormAsync() {
if (!canSubmit) return;
loading = true;
- const request = await fulfill_forgot_password_request(
- data.resetRequestId,
- formData.newPassword
- );
+ const request = await fulfill_forgot_password_request(data.resetRequestId, formData.newPassword);
if (request.ok) {
- goto(
- "/sign-in?" +
- messageQueryKey +
- "=" +
- Message.AFTER_PASSWORD_RESET
- );
+ goto("/sign-in?" + messageQueryKey + "=" + Message.AFTER_PASSWORD_RESET);
}
loading = false;
@@ -49,9 +38,7 @@
onMount(async () => {
errorState = undefined;
- const isValidRequest = await check_forgot_password_request(
- data.resetRequestId
- );
+ const isValidRequest = await check_forgot_password_request(data.resetRequestId);
if (!isValidRequest.ok && isValidRequest.status !== 404) {
errorState = "unknown";
canSubmit = false;
@@ -84,15 +71,9 @@
<div class="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
<div class="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
- <form
- class="space-y-6"
- on:submit|preventDefault={submitFormAsync}
- >
+ <form class="space-y-6" on:submit|preventDefault={submitFormAsync}>
{#if errorState === "404"}
- <Alert
- title={$LL.notFound()}
- message={$LL.resetPasswordPage.requestNotFound()}
- />
+ <Alert title={$LL.notFound()} message={$LL.resetPasswordPage.requestNotFound()} />
{:else if errorState === "expired"}
<Alert
title={$LL.resetPasswordPage.expired()}
@@ -101,10 +82,7 @@
rightLinkText={$LL.resetPasswordPage.requestANewReset()}
/>
{:else if errorState === "unknown"}
- <Alert
- title={$LL.unexpectedError()}
- message={$LL.tryAgainSoon()}
- />
+ <Alert title={$LL.unexpectedError()} message={$LL.tryAgainSoon()} />
{/if}
<Input
@@ -117,12 +95,7 @@
label={$LL.resetPasswordPage.newPassword()}
/>
- <Button
- text={$LL.submit()}
- type="submit"
- {loading}
- fullWidth
- />
+ <Button text={$LL.submit()} type="submit" {loading} fullWidth />
</form>
</div>
</div>