From dce12a5ccff91bd2b985c9664ca29a4c1a083cf2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 21 Mar 2023 09:58:45 -0700 Subject: pin code refactor --- .../(app)/[username]/settings/[...tab]/+page.svelte | 7 ++----- .../[username]/settings/[...tab]/_security.svelte | 6 +++--- src/routes/(app)/login/+page.svelte | 8 ++++++++ src/routes/(app)/payment/[id]/+page.svelte | 8 ++++---- src/routes/(app)/send/+layout.svelte | 21 +-------------------- 5 files changed, 18 insertions(+), 32 deletions(-) (limited to 'src/routes') diff --git a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte index 997d8b4a..1b212abe 100644 --- a/src/routes/(app)/[username]/settings/[...tab]/+page.svelte +++ b/src/routes/(app)/[username]/settings/[...tab]/+page.svelte @@ -112,13 +112,10 @@ loading = false; } - - let loaded; - onMount(() => setTimeout(() => (loaded = true), 50)); -{#if loaded && user.haspin && $pin?.length !== 6} - +{#if user.haspin && $pin?.length !== 6} + {/if}
{#if verifying} - + {:else if settingPin} - + {:else} + {/if} diff --git a/src/routes/(app)/send/+layout.svelte b/src/routes/(app)/send/+layout.svelte index e5c9c051..6192cd40 100644 --- a/src/routes/(app)/send/+layout.svelte +++ b/src/routes/(app)/send/+layout.svelte @@ -8,30 +8,11 @@ export let data; - let loaded; let { user } = data; - - onMount(() => setTimeout(() => (loaded = true), 500)); let cancel = () => goto(`/${user.username}`); - - $: browser && loaded && checkPin($pin); - let checkPin = async (p) => { - if (p?.length !== 6 || p === JSON.parse(sessionStorage.getItem('pin'))) return; - let result; - try { - result = await post('/pin', { pin: p }); - } catch (e) {} - - if (result) { - success('Pin confirmed'); - } else { - fail('Invalid pin'); - $pin = ''; - } - }; -{#if loaded && user.haspin && (!$pin || $pin?.length !== 6)} +{#if user.haspin && (!$pin || $pin?.length !== 6)} {/if} -- cgit v1.2.3