From 5f7474140fd37ed86cd77d489768638e73fa2f8d Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Fri, 6 Mar 2026 14:58:25 -0800 Subject: [PATCH] Add StringMultiInput for OTPs --- src/app/components/KeyRecoveryConfirm.svelte | 23 +----- src/app/components/LogInOTPConfirm.svelte | 23 +----- src/app/components/PasswordReset.svelte | 24 +----- src/lib/components/StringMultiInput.svelte | 77 ++++++++++++++++++++ 4 files changed, 89 insertions(+), 58 deletions(-) create mode 100644 src/lib/components/StringMultiInput.svelte diff --git a/src/app/components/KeyRecoveryConfirm.svelte b/src/app/components/KeyRecoveryConfirm.svelte index 82ed7314..9aed79d4 100644 --- a/src/app/components/KeyRecoveryConfirm.svelte +++ b/src/app/components/KeyRecoveryConfirm.svelte @@ -15,10 +15,10 @@ import ModalTitle from "@lib/components/ModalTitle.svelte" import ModalSubtitle from "@lib/components/ModalSubtitle.svelte" import ModalFooter from "@lib/components/ModalFooter.svelte" + import StringMultiInput from "@lib/components/StringMultiInput.svelte" import KeyDownload from "@app/components/KeyDownload.svelte" import {pushToast} from "@app/util/toast" import {pushModal, clearModals} from "@app/util/modal" - import {POMADE_SIGNERS} from "@app/core/state" type Props = { peersByPrefix: Map @@ -32,18 +32,6 @@ } = $session as SessionPomade const confirmRecovery = async () => { - const otps = input - .split(/\n/) - .map(x => x.trim()) - .filter(x => x.match(/^[0-9]{8}$/)) - - if (otps.length < 2) { - return pushToast({ - theme: "error", - message: "Failed to recover, not enough valid recovery codes were provided.", - }) - } - const request = await Client.recoverWithChallenge(email, peersByPrefix, otps) if (!request.ok) { @@ -82,7 +70,7 @@ const back = () => history.back() let loading = $state(false) - let input = $state("") + let otps = $state([]) @@ -96,17 +84,14 @@ For security reasons, you may receive three or more emails with recovery codes in them. Please paste all recovery codes into the text box below, on separate lines.

- + - diff --git a/src/app/components/LogInOTPConfirm.svelte b/src/app/components/LogInOTPConfirm.svelte index ad031926..2ed0f946 100644 --- a/src/app/components/LogInOTPConfirm.svelte +++ b/src/app/components/LogInOTPConfirm.svelte @@ -13,8 +13,8 @@ import ModalTitle from "@lib/components/ModalTitle.svelte" import ModalSubtitle from "@lib/components/ModalSubtitle.svelte" import ModalFooter from "@lib/components/ModalFooter.svelte" + import StringMultiInput from "@lib/components/StringMultiInput.svelte" import LogInSelect from "@app/components/LogInSelect.svelte" - import {POMADE_SIGNERS} from "@app/core/state" import {pushToast} from "@app/util/toast" import {setChecked} from "@app/util/notifications" import {pushModal, clearModals} from "@app/util/modal" @@ -30,18 +30,6 @@ const back = () => history.back() const onSubmit = async () => { - const otps = input - .split(/\n/) - .map(x => x.trim()) - .filter(x => x.match(/^[0-9]{8}$/)) - - if (otps.length < 3) { - return pushToast({ - theme: "error", - message: "Not enough valid recovery codes were provided.", - }) - } - loading = true try { @@ -85,7 +73,7 @@ } } - let input = $state("") + let otps = $state([]) let loading = $state(false) @@ -100,17 +88,14 @@ For security reasons, you may receive three or more emails with login codes in them. Please paste all login codes into the text box below, on separate lines.

- + - diff --git a/src/app/components/PasswordReset.svelte b/src/app/components/PasswordReset.svelte index 45d22dde..76ca5422 100644 --- a/src/app/components/PasswordReset.svelte +++ b/src/app/components/PasswordReset.svelte @@ -14,8 +14,8 @@ import ModalTitle from "@lib/components/ModalTitle.svelte" import ModalSubtitle from "@lib/components/ModalSubtitle.svelte" import ModalFooter from "@lib/components/ModalFooter.svelte" + import StringMultiInput from "@lib/components/StringMultiInput.svelte" import PasswordResetConfirm from "@app/components/PasswordResetConfirm.svelte" - import {POMADE_SIGNERS} from "@app/core/state" import {pushToast} from "@app/util/toast" import {pushModal} from "@app/util/modal" import {getPomadeClient} from "@app/util/pomade" @@ -29,19 +29,6 @@ const {email} = $session as SessionPomade const confirmRecovery = async () => { - const otps = input - .split(/\n/) - .map(x => x.trim()) - .filter(x => x.match(/^[0-9]{8}$/)) - - if (otps.length < 2) { - return pushToast({ - theme: "error", - message: - "Failed to validate email ownership, not enough valid recovery codes were provided.", - }) - } - const request = await Client.recoverWithChallenge(email, peersByPrefix, otps) if (!request.ok) { @@ -90,7 +77,7 @@ const back = () => history.back() let loading = $state(false) - let input = $state("") + let otps = $state([]) @@ -104,17 +91,14 @@ For security reasons, you may receive three or more emails with confirmation codes in them. Please paste all confirmation codes into the text box below, on separate lines.

- + - diff --git a/src/lib/components/StringMultiInput.svelte b/src/lib/components/StringMultiInput.svelte new file mode 100644 index 00000000..1ca07f60 --- /dev/null +++ b/src/lib/components/StringMultiInput.svelte @@ -0,0 +1,77 @@ + + +
+
+ {#each value as item (item)} +
+ + {item} +
+ {/each} +
+ +