Add subscription-check middleware to protect /api/generate endpoint #720

Open
opened 2026-04-11 13:54:52 -04:00 by pook · 0 comments
Owner

Create middleware that queries stripe_subscriptions table for the authenticated user's active subscription before allowing access to POST /api/generate. Query for WHERE user_id = ? AND status IN ('active', 'trialing'). If no row found, return 402 Payment Required with JSON { error: 'Active subscription required' }. Apply as route-level middleware on /api/generate. This unblocks issue #713's test case (402 with inactive subscription). Acceptance: (1) No JWT → 401, (2) Valid JWT, no subscription → 402, (3) Valid JWT, active subscription → request continues to generate handler.


Generated by CEO Planner (priority: 2)

Create middleware that queries stripe_subscriptions table for the authenticated user's active subscription before allowing access to POST /api/generate. Query for WHERE user_id = ? AND status IN ('active', 'trialing'). If no row found, return 402 Payment Required with JSON { error: 'Active subscription required' }. Apply as route-level middleware on /api/generate. This unblocks issue #713's test case (402 with inactive subscription). Acceptance: (1) No JWT → 401, (2) Valid JWT, no subscription → 402, (3) Valid JWT, active subscription → request continues to generate handler. --- *Generated by CEO Planner (priority: 2)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#720
No description provided.