Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Handle a failed competing send and the end of the cooldown
Claude92b4e918b4fb
diff --git a/src/components/signing/signer-verification-screen.tsx b/src/components/signing/signer-verification-screen.tsxindex 880329e..c8748c1 100644--- a/src/components/signing/signer-verification-screen.tsx+++ b/src/components/signing/signer-verification-screen.tsx@@ -131,11 +131,18 @@ export function SignerVerificationScreen({}const timer = window.setTimeout(() => {- setResendWait((seconds) => Math.max(0, seconds - 1));+ if (resendWait <= 1) {+ setResendWait(0);+ setNotice(+ `A code was sent to ${state.maskedEmail}. If it has not arrived, you can send a new one now.`,+ );+ } else {+ setResendWait(resendWait - 1);+ }}, 1000);return () => window.clearTimeout(timer);- }, [resendWait]);+ }, [resendWait, state.maskedEmail]);const copy = METHOD_COPY[method];const step = state.required.indexOf(method) + 1;diff --git a/src/lib/signing.ts b/src/lib/signing.tsindex e2060b3..934ee9f 100644--- a/src/lib/signing.ts+++ b/src/lib/signing.ts@@ -1433,11 +1433,19 @@ export async function sendSignerEmailCode();}- // Another request claimed the window first and sent the code.+ // Another request claimed the window first. Its code is the one to use,+ // unless that send failed and cleared it again in the meantime.const current = await getSignerCheckState(context.signer.id!, database);+ if (current.emailCodeHash === null || current.emailCodeSentAt === null) {+ throw new SigningMutationError(+ "The code could not be sent right now. Try again.",+ 503,+ );+ }+return cooldownResult(- current.emailCodeSentAt ?? now,+ current.emailCodeSentAt,now,maskEmailAddress(context.signer.email),);