deckhearth/pages
Randall Stillwell 1fca3aa1ca fix(api): return 401 (not 500) on unauthenticated cards-collection writes
Follow-up to fix-auth-bypass Brief 2 (commit 258e479). Brief 2 made
getUserFromRequest return null for unauthenticated requests. POST, PUT,
and DELETE branches of pages/api/collections/[identifier]/cards.js
were dereferencing user.userId without a guard → NPE → HTTP 500.

Security side was already fixed by Brief 2 (no more
anonymous-write-as-admin on collections owned by userId: 1). This patch
adds the cosmetic 500 → 401 cleanup the Brief 2 reviewer flagged.

Three identical 'if (!user) return 401' guards added, one per write
branch. GET branch was already guarded via the ternary pattern.

Sibling endpoints under pages/api/collections/** were re-audited by the
implementer and confirmed correctly guarded (thumbnails, permissions,
activity all have early null checks; [identifier].js uses optional
chaining throughout). No further hotfixes needed for that route group.

Convoy: fix-auth-bypass / Brief 6 (post-architect hotfix)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-23 11:04:55 -05:00
..
admin Fixed SSR and null user issues for production deployment 2025-07-24 17:04:06 -05:00
api fix(api): return 401 (not 500) on unauthenticated cards-collection writes 2026-05-23 11:04:55 -05:00
card Major Scanner Improvements 2025-07-29 14:19:48 -05:00
collection Major Scanner Improvements 2025-07-29 14:19:48 -05:00
community Major Scanner Improvements 2025-07-29 14:19:48 -05:00
deck Major Scanner Improvements 2025-07-29 14:19:48 -05:00
invite 🎉 COMPLETED: Full Collaborative Collections System 2025-07-25 08:34:28 -05:00
_app.js Major redesign: Enhanced card display with particle effects, improved filters, and search functionality 2025-07-23 21:26:54 -05:00
cards.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
collections.js 🔧 Fix System Collections & Database Schema Issues 2025-07-27 19:17:55 -05:00
dashboard.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
deck-builder.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
decks.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
index.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
login.js Clean Up Login & Add Signup Flow 2025-07-28 11:09:58 -05:00
logout.js 🎨 Restructured Layout System 2025-07-25 11:28:04 -05:00
my-cards.js Major Scanner Improvements 2025-07-29 14:19:48 -05:00
profile.js 🎯 Build Comprehensive User Profile & Settings System 2025-07-26 18:05:55 -05:00
scanner.js Marker: Fixed card queue property mismatch - cards now properly separate in scanner queue 2025-08-01 17:41:42 -05:00
settings.js 🎯 Build Comprehensive User Profile & Settings System 2025-07-26 18:05:55 -05:00
signup.js 🎨 Enhanced Signup with Username & Profile Images 2025-07-28 11:18:58 -05:00