Skip to content

fix(api): harden swipe access and quotas - #179

Merged
GSTJ merged 1 commit into
mainfrom
security/harden-swipes
Aug 31, 2026
Merged

fix(api): harden swipe access and quotas#179
GSTJ merged 1 commit into
mainfrom
security/harden-swipes

Conversation

@GSTJ

@GSTJ GSTJ commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

We now gate protected API routes on active accounts and serialize concurrent swipe writes to enforce the free-plan rolling quota and prevent duplicate interest or match state.

Details

  • Require an active account for protected routes while keeping account deletion available.
  • Reject self, banned, deleted, and hidden profiles from the swipe deck and direct swipes.
  • Use PostgreSQL transaction locks for free-plan quota and dog-pair writes, and preserve the last positive swipe timestamp through dislikes and dog replacement.
  • Deduplicate old requester/responder pairs before adding a unique database constraint, while preserving their latest positive swipe time.
  • Create and close matches inside the same transaction, then send notifications after it commits.

Testing steps

  • Use a blocked account and confirm protected actions fail while account deletion still succeeds.
  • Try to swipe your own profile and banned, deleted, or hidden profiles; each should be unavailable.
  • Send more concurrent free-plan likes than the 24-hour limit allows; only the allowed likes should succeed.
  • Like profiles, dislike some of them, replace the current dog profile, and confirm earlier positive likes still count toward the 24-hour free-plan limit.
  • Have two profiles like each other at the same time and confirm there is one active match.
  • pnpm test
  • pnpm typecheck
  • pnpm lint
  • pnpm format
  • pnpm exec dotenv -e .env.test -- pnpm -F @pegada/nextjs build

Copilot AI lite review requested due to automatic review settings August 31, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@GSTJ

GSTJ commented Aug 31, 2026

Copy link
Copy Markdown
Owner Author

Local proof for 8f7caa9: targeted security tests, a fresh PostgreSQL migration, the full repository suite, typecheck, lint, formatting, and the production Next.js build.

Swipe security proof

@GSTJ
GSTJ merged commit ee2cb23 into main Aug 31, 2026
13 checks passed
@GSTJ
GSTJ deleted the security/harden-swipes branch August 31, 2026 14:44
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.

2 participants