diff options
| author | Adam Soltys <[email protected]> | 2025-01-07 14:42:03 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-01-07 14:42:03 -0800 |
| commit | 2358d1bf39c34a508db6c50f0f6312ee411a8a17 (patch) | |
| tree | c1a592710013c0db2f4d992f6884f4fd371f125d /src/routes | |
| parent | 493cb3a3504fdc2791d47fd032f5ac9d2ccc66b7 (diff) | |
| download | coinos-ui-2358d1bf39c34a508db6c50f0f6312ee411a8a17.tar.gz coinos-ui-2358d1bf39c34a508db6c50f0f6312ee411a8a17.zip | |
nostr signin
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/(app)/+layout.svelte | 6 | ||||
| -rw-r--r-- | src/routes/(app)/settings/+layout.svelte | 14 | ||||
| -rw-r--r-- | src/routes/(app)/settings/security/+page.svelte | 3 | ||||
| -rw-r--r-- | src/routes/(static)/login/+page.svelte | 2 | ||||
| -rw-r--r-- | src/routes/(static)/register/+page.server.ts | 7 | ||||
| -rw-r--r-- | src/routes/(static)/register/+page.svelte | 21 |
6 files changed, 20 insertions, 33 deletions
diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 31238a87..e179005f 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -8,6 +8,7 @@ request, ndef, passwordPrompt, + signaturePrompt, password, pin, theme as themeStore, @@ -16,6 +17,7 @@ import { browser } from "$app/environment"; import LoadingSplash from "$comp/LoadingSplash.svelte"; import AppHeader from "$comp/AppHeader.svelte"; + import Nostr from "$comp/Nostr.svelte"; import Password from "$comp/Password.svelte"; import { getCookie, warning } from "$lib/utils"; import { t, locale, loading } from "$lib/translations"; @@ -89,6 +91,10 @@ <Password {user} /> {/if} +{#if browser && $signaturePrompt} + <Nostr event={$signaturePrompt} /> +{/if} + <svelte:head> {#if subject} <title>coinos - {subject.username}</title> diff --git a/src/routes/(app)/settings/+layout.svelte b/src/routes/(app)/settings/+layout.svelte index 134b8933..85e5b0e6 100644 --- a/src/routes/(app)/settings/+layout.svelte +++ b/src/routes/(app)/settings/+layout.svelte @@ -12,7 +12,7 @@ import { avatar, banner, password, pin, save } from "$lib/store"; import { upload } from "$lib/upload"; import { page } from "$app/stores"; - import { sign, send, reEncryptEntropy, setNsec } from "$lib/nostr"; + import { sign, send, setNsec } from "$lib/nostr"; import { invalidateAll } from "$app/navigation"; let { children, data, form } = $props(); @@ -59,18 +59,6 @@ data.set("pubkey", user.pubkey); } - if (data.get("password")) { - try { - data.set( - "cipher", - await reEncryptEntropy(prev, data.get("password")), - ); - } catch (e) { - console.log("Failed to encrypt keys with new password"); - throw e; - } - } - if ($avatar) { try { let { hash } = JSON.parse( diff --git a/src/routes/(app)/settings/security/+page.svelte b/src/routes/(app)/settings/security/+page.svelte index 3a427546..5d4b492f 100644 --- a/src/routes/(app)/settings/security/+page.svelte +++ b/src/routes/(app)/settings/security/+page.svelte @@ -1,6 +1,5 @@ <script> import { getContext } from "svelte"; - import { getMnemonic } from "$lib/nostr"; import { tick } from "svelte"; import { t } from "$lib/translations"; import Pin from "$comp/Pin.svelte"; @@ -19,7 +18,6 @@ let confirming2fa = $state(), disabling2fa = $state(), importing = $state(), - mnemonic = $state(), newNsec = $state(), nsec = $state(), otp = $state(), @@ -50,7 +48,6 @@ let toggleSeed = async () => { try { - mnemonic = await getMnemonic(user); revealSeed = !revealSeed; } catch (e) { console.log(e); diff --git a/src/routes/(static)/login/+page.svelte b/src/routes/(static)/login/+page.svelte index ca6ebf73..7e8234ee 100644 --- a/src/routes/(static)/login/+page.svelte +++ b/src/routes/(static)/login/+page.svelte @@ -164,4 +164,4 @@ </div> {/if} -<Nostr {id} {nostrSignin} {redirect} {token} /> +<Nostr {id} bind:nostrSignin {redirect} {token} /> diff --git a/src/routes/(static)/register/+page.server.ts b/src/routes/(static)/register/+page.server.ts index 561b34a0..bf908c54 100644 --- a/src/routes/(static)/register/+page.server.ts +++ b/src/routes/(static)/register/+page.server.ts @@ -1,4 +1,4 @@ -import { get, fd, login, post } from "$lib/utils"; +import { fd, get, login, post } from "$lib/utils"; import { fail, redirect } from "@sveltejs/kit"; export const load = async ({ parent }) => { @@ -16,9 +16,8 @@ export const actions = { const ip = request.headers.get("cf-connecting-ip"); const form = await fd(request); - let { picture, username, password, cipher, salt, pubkey, loginRedirect } = - form; - const user = { picture, username, password, cipher, salt, pubkey }; + let { picture, username, password, pubkey, loginRedirect } = form; + const user = { picture, username, password, pubkey }; let error; if (loginRedirect === "undefined") loginRedirect = undefined; diff --git a/src/routes/(static)/register/+page.svelte b/src/routes/(static)/register/+page.svelte index 69c6a588..77394e1a 100644 --- a/src/routes/(static)/register/+page.svelte +++ b/src/routes/(static)/register/+page.svelte @@ -1,6 +1,5 @@ <script> import { browser } from "$app/environment"; - import { onMount } from "svelte"; import punks from "$lib/punks"; import { upload } from "$lib/upload"; import { afterNavigate, invalidateAll } from "$app/navigation"; @@ -9,6 +8,7 @@ import { fly } from "svelte/transition"; import { enhance } from "$app/forms"; + import Nostr from "$comp/Nostr.svelte"; import Pin from "$comp/Pin.svelte"; import Spinner from "$comp/Spinner.svelte"; import PasswordInput from "$comp/PasswordInput.svelte"; @@ -26,12 +26,9 @@ } from "unique-names-generator"; let { form, data } = $props(); - let nostr = $state(); let { id } = $derived(data); - onMount(() => { - if (browser && window.nostr) nostr = true; - }); + let nostrSignin = $state(); let username = $state(); let { index } = $state(data); @@ -113,7 +110,7 @@ } catch (e) { console.log("problem uploading avatar", e); } - } + } const response = await fetch("/register", { method: "POST", @@ -312,12 +309,10 @@ {/if} </button> - {#if nostr} - <button type="button" class="btn" onclick={nostrLogin}> - <img src="/images/nostr.png" class="w-8" /> - <div class="my-auto">{$t("login.nostr")}</div> - </button> - {/if} + <button type="button" class="btn" onclick={() => (nostrSignin = true)}> + <img src="/images/nostr.png" class="w-8" /> + <div class="my-auto">{$t("login.nostr")}</div> + </button> <p class="text-secondary text-center font-medium"> {$t("login.haveAccount")} @@ -330,3 +325,5 @@ </p> </form> </div> + +<Nostr {id} {nostrSignin} {redirect} {token} /> |
