Skip to content

fix(api): validate the emailed approval token on the delayed-approval path - #589

Merged
cristim merged 1 commit into
mainfrom
fix/delayed-approval-validate-token
Oct 6, 2026
Merged

cristim merged 1 commit into
mainfrom
fix/delayed-approval-validate-token

Conversation

@cristim

@cristim cristim commented Oct 6, 2026

Copy link
Copy Markdown
Member

Closes #586

With a purchase delay configured, approveViaToken called approveWithDelay without checking the emailed token; only the immediate path (ApproveExecution) did. A contact-email session with token WRONG got 200 "scheduled".

Tests through HandleRequest (delay 1h): wrong token 403, expired 410, no stored token 403, valid token schedules 200, scheduled replay 409. The three rejection cases returned 200 before the fix.

🤖 Generated with Claude Code

… path

approveViaToken went straight to approveWithDelay when a purchase delay was configured, so only the immediate path (ApproveExecution) checked the token. Export purchase.ValidateApprovalToken, call it before scheduling and map errors through tokenActionError (403 invalid, 410 expired). Closes #586.
@cristim cristim added triaged Item has been triaged priority/p1 Next up; this sprint severity/high Significant harm urgency/this-quarter Within the quarter impact/few Limited audience effort/s Hours type/bug Defect labels Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 4 billable files and costs up to $1.00.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 38 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: f3aa5366-e960-4063-a8e9-4f0f8e355d45
📥 Commits

Reviewing files that changed from the base of the PR and between bbd5297 and f3be5c9.

📒 Files selected for processing (4)
  • internal/api/handler_purchases.go
  • internal/api/handler_purchases_delay_token_test.go
  • internal/api/openapi.yaml
  • internal/purchase/approvals.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/s Hours impact/few Limited audience priority/p1 Next up; this sprint severity/high Significant harm triaged Item has been triaged type/bug Defect urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sec(api): delayed approval via emailed token never validates the token when purchase_delay_hours > 0

1 participant