- New `lib/auth-secret.js` is the single source of truth for `JWT_SECRET`
and the canonical `JWT_TOKEN_TTL = '24h'`. Module throws at import time
if `process.env.JWT_SECRET` is unset — no silent fallback to the literal
`'your-secret-key-change-in-production'`.
- 7 callers refactored to import from the helper:
lib/permission-middleware.js
pages/api/auth-utils.js (also drops unused `'7d'` → JWT_TOKEN_TTL)
pages/api/auth/login.js (also routes via auth-utils.generateToken)
pages/api/auth/register.js (same)
pages/api/auth/verify.js (Brief 2 still owns the no-token admin branch)
pages/api/favorites.js
pages/api/users/search.js
- `process.env.JWT_SECRET` now appears exactly once in the JS source
(lib/auth-secret.js). `your-secret-key-change-in-production` is gone.
- TTL drift reconciled: auth-utils used `'7d'`, login/register used
inline `'24h'`. Both now route through imported `JWT_TOKEN_TTL` (24h).
Pre-deploy reminder: Vercel must have `JWT_SECRET` set before merge or
serverless functions refuse to boot. Existing tokens (signed against the
fallback literal) will be invalidated — users will need to log in again.
Resolves AGENTS.md gotcha #3. Brief 2/3/4/5 still pending in convoy.
Convoy: fix-auth-bypass / Brief 1
Co-authored-by: Cursor <cursoragent@cursor.com>
Built out all requested features from top to bottom:
✅ Upload Modal for Hero Images:
- Created UploadImageModal component with drag-and-drop
- Support for both URL input and file upload
- Live preview and validation
- Integrated into collection detail page
✅ Smart TCG Tags:
- Dynamic tags showing only games with cards
- Properly positioned under description
- Clean blue rounded styling
✅ Combined Share & Invite Modal:
- Unified ShareModal replacing separate buttons
- Public access toggle with community visibility
- Email/member search functionality
- Default viewer role for invitations
- Social sharing (Twitter, Facebook, Reddit, Discord)
- User search API endpoint (/api/users/search)
✅ Comprehensive Favorites System:
- Database schema for cards, collections, and decks
- API endpoint (/api/favorites) for CRUD operations
- Real-time favorite status checking
- Working toggle functionality in UI
- Migration script for database setup
✅ CSV Download Functionality:
- Complete card metadata export
- Proper CSV formatting with escaping
- All card fields included (name, set, rarity, etc.)
- Automatic filename generation
- Client-side download implementation
🎯 UI/UX Improvements:
- Removed duplicate buttons and switches
- Clean action bar with proper hierarchy
- Working modals with proper state management
- Error handling and loading states
🛠️ Technical Features:
- JWT authentication for all endpoints
- Proper database relationships and indexes
- CORS headers and error handling
- Optimized queries and performance
All todos completed! Ready for full collection management! 🎮✨