Fix: Associate comparisons with authenticated user #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Currently
POST /api/comparecreates comparisons withuserIdnot set (no auth check). The server actioncreateComparisonalso doesn't set userId. Comparisons need to be linked to the user who created them.Implementation
In
src/app/api/compare/route.ts:userIdwhen inserting intocomparisonstableIn
src/app/actions/comparison.ts:createComparisonshould accept userId and set itgetUserComparisonsalready filters by userId (line 94-100) — just needs to be called with real sessionRecommendation: Require authentication for creating comparisons. The compare page should redirect to sign-in if not authenticated.
Files
src/app/api/compare/route.ts(line 55-61 — add userId)src/app/actions/comparison.ts(line 9-42 — add userId param)src/lib/auth.ts(Better Auth server config for session extraction)Acceptance Criteria