Skip to content

fix(api): preserve verification token on resend mail failure - #120

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-0d41
Draft

fix(api): preserve verification token on resend mail failure#120
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-0d41

Conversation

@cursor

@cursor cursor Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

POST /v1/agent/verify-email/resend rotated an unverified account's stored verification token before confirming email delivery. If Resend/Postmark returned an error or was unavailable, the endpoint still returned the neutral success message while the previous usable verification link was invalidated, leaving pending signup credits locked until a later successful resend.

Root cause

sendEmail() returned false on delivery failure, but sendVerificationEmail() discarded that result and always logged success. The resend path updated verifyToken/verifyTokenExpiry and launched the send without any failure compensation.

Fix

  • Make verification email sending return its delivery result.
  • Preserve anti-enumeration response behavior by keeping resend fire-and-forget.
  • On background delivery failure, guard-rollback only the just-minted token to the previous token/expiry so newer resends are not clobbered.
  • Add a regression test for slow provider failure: the route returns neutral 200 before the provider completes, then restores the previous token.

Validation

  • npm run build
  • node tests/verify-resend.test.mjs
Open in Web View Automation 

Co-authored-by: Deesmo <Deesmo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant