From 8940118dd22c5f2ab680ef8036bcfafecc5696ab Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 7 Dec 2023 22:34:23 -0800 Subject: password reset --- src/locales/en.json | 3 +- src/routes/(app)/+layout.server.js | 5 +- src/routes/(app)/+layout.svelte | 6 +- src/routes/(app)/[username]/generate/+page.svelte | 12 +++- src/routes/(app)/forgot/+page.server.js | 4 +- src/routes/(app)/forgot/+page.svelte | 62 +++++++++++------- src/routes/(app)/login/+page.svelte | 2 +- src/routes/(app)/reset/[code]/+page.server.js | 30 +++++++++ src/routes/(app)/reset/[code]/+page.svelte | 80 +++++++++++++++++++++++ 9 files changed, 168 insertions(+), 36 deletions(-) create mode 100644 src/routes/(app)/reset/[code]/+page.server.js create mode 100644 src/routes/(app)/reset/[code]/+page.svelte (limited to 'src') diff --git a/src/locales/en.json b/src/locales/en.json index 0dda9362..6d10da6c 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -123,9 +123,10 @@ "token": "2FA Token", "username": "Username", "password": "Password", + "newPassword": "New password", "email": "Email", "passwordRecommendation": "We recommend using a long, random password if you intend to keep funds in your account.", - "forgotUserOrPassword": "Forgot Username or Password?", + "forgotUserOrPassword": "Forgot password?", "haveAccount": "Already have an account?", "noAccount": "Don't have an account?", "register": "Register", diff --git a/src/routes/(app)/+layout.server.js b/src/routes/(app)/+layout.server.js index 9fcf6411..67250769 100644 --- a/src/routes/(app)/+layout.server.js +++ b/src/routes/(app)/+layout.server.js @@ -34,8 +34,9 @@ export async function load({ cookies, request, url, params }) { throw redirect(307, "/login"); } - if (user && !user.pubkey && !pathname.includes("generate")) - throw redirect(307, `/${user.username}/generate`); + if (user && !user.pubkey && !pathname.includes("generate")) { + throw redirect(303, `/${user.username}/generate`); + } try { rate = await get("/rate"); diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 2d3aa192..237e931c 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -8,18 +8,18 @@ request, ndef, passwordPrompt, + password, pin, } from "$lib/store"; import { page } from "$app/stores"; import { browser } from "$app/environment"; - import { goto } from "$app/navigation"; import LoadingSplash from "$comp/LoadingSplash.svelte"; import Invoice from "$comp/Invoice.svelte"; import Password from "$comp/Password.svelte"; import Request from "$comp/Request.svelte"; import { warning, protectedRoutes } from "$lib/utils"; import { t, locale } from "$lib/translations"; - import { onNavigate } from "$app/navigation"; + import { goto, onNavigate } from "$app/navigation"; export let data; @@ -34,7 +34,7 @@ }); }); - let { rate, user, subject, token, rates } = data; + let { generate, rate, user, subject, token, rates } = data; $: update(data); let update = (data) => { diff --git a/src/routes/(app)/[username]/generate/+page.svelte b/src/routes/(app)/[username]/generate/+page.svelte index 71f828dc..0c83fad4 100644 --- a/src/routes/(app)/[username]/generate/+page.svelte +++ b/src/routes/(app)/[username]/generate/+page.svelte @@ -3,6 +3,7 @@ import { onMount } from "svelte"; import { goto, invalidate } from "$app/navigation"; import Pin from "$comp/Pin.svelte"; + import Spinner from "$comp/Spinner.svelte"; import { loginRedirect, pin, password, passwordPrompt } from "$lib/store"; import { generate } from "$lib/nostr"; import { browser } from "$app/environment"; @@ -19,6 +20,7 @@ return; } + console.log("PASSWORRRRD", $password); if (!$password) $passwordPrompt = true; try { @@ -58,6 +60,10 @@ {#if loaded && user?.haspin && $pin?.length !== 6} {/if} -{loaded} -{JSON.stringify(user)} -{$pin} + +
+

Generating new account keys

+
+ +
+
diff --git a/src/routes/(app)/forgot/+page.server.js b/src/routes/(app)/forgot/+page.server.js index db2005e7..48411539 100644 --- a/src/routes/(app)/forgot/+page.server.js +++ b/src/routes/(app)/forgot/+page.server.js @@ -3,13 +3,11 @@ import { fd, post, login } from "$lib/utils"; export const actions = { default: async ({ request }) => { - let { email } = await fd(request); - try { + let { email } = await fd(request); await post("/forgot", { email }); return { success: true }; } catch (e) { - console.log(e.message); return fail(400, { error: e.message }); } }, diff --git a/src/routes/(app)/forgot/+page.svelte b/src/routes/(app)/forgot/+page.svelte index 91c4290a..9490d531 100644 --- a/src/routes/(app)/forgot/+page.svelte +++ b/src/routes/(app)/forgot/+page.svelte @@ -1,4 +1,6 @@ + +
+
+ + + +
+ +
+
+

{$t("login.reset")}

+ + {#if form?.error} +
+ {form.error} +
+ {/if} + +
+
+ + {#if revealPassword} + + {:else} + + {/if} + +
+ +
A new seed phrase will be generated for your account. You'll need to import your old seed phrase if you want to use the same nostr profile and savings account as before.
+ + +
+
+
+
-- cgit v1.2.3