Commit graph

7 commits

Author SHA1 Message Date
Randall Stillwell
7463551065 Move OCR settings to comprehensive user settings system
🏗️ User Settings System:
- Create comprehensive Settings page with tabbed interface
- Move OCR configuration from modal to dedicated settings tab
- Add API endpoints for user preferences (GET/PUT)
- Store settings in database user_preferences table with ocr_settings column
- Add Settings link to navbar user dropdown

⚙️ Settings Features:
- General tab: default view, items per page, theme, animations
- AI OCR tab: service selection, API keys, confidence threshold
- Privacy tab: public collections/decks defaults
- Real-time API key testing for OpenAI and Ollama
- Persistent storage in database instead of localStorage

🔄 Integration:
- Remove old OCRSettings modal from Scanner page
- Add Settings route to App.tsx routing
- Update navbar with Settings link in user dropdown
- Prepare for AI OCR service to read from user preferences

Next: Update AI OCR service to use saved user preferences instead of localStorage
2025-07-22 10:53:44 -05:00
Randall Stillwell
08e2664a9a Fix admin users API endpoint
🔧 Convert TypeScript to JavaScript:
- Replace api/admin/users.ts with api/admin/users.js
- Use req, res pattern instead of NextRequest/NextResponse
- Fix req.headers.get() -> req.headers.authorization
- Use url.parse() for query parameters
- Support GET (list users), PUT (update), DELETE (deactivate)
- Proper admin authentication and error handling

Resolves: req.headers.get is not a function error
2025-07-22 07:36:37 -05:00
Randall Stillwell
5dd7de86ad Add debug logging to promote-user endpoint
🐛 Debug:
- Log request body type and content
- Identify why JSON parsing is failing
- Temporary debug version to diagnose issue
2025-07-22 07:10:14 -05:00
Randall Stillwell
028c5396f3 Fix promote-user endpoint request body parsing
🔧 Fix:
- Use req.body directly instead of req.text() + JSON.parse()
- Match pattern used in working auth endpoints
- Should resolve NOT_FOUND and parsing issues
2025-07-22 07:09:14 -05:00
Randall Stillwell
f7735ba8d9 Add user promotion endpoint
🔧 Admin Management:
- Add api/admin/promote-user.js endpoint
- Allows promoting users to admin role by username or userId
- Checks for existing admin status
- Returns updated user info with roles
- Handles database errors gracefully

Usage: POST /api/admin/promote-user with { username: 'testuser' }
2025-07-22 07:08:09 -05:00
Randall Stillwell
07b3dda6fa Fix Vercel function request body parsing
🐛 Bug Fix:
- Replace req.json() with req.text() + JSON.parse() for Vercel compatibility
- Add proper error handling for malformed JSON requests
- Fix authentication endpoints (login/register) body parsing
- Fix admin users endpoint body parsing

🔧 Technical Details:
- Vercel functions don't support req.json() method directly
- Use req.text() to get raw body content then parse manually
- Add try/catch blocks for JSON parsing errors
- Maintain same API interface and error responses

 Endpoints Fixed:
- /api/auth/register - User registration
- /api/auth/login - User authentication
- /api/admin/users - Admin user management

This resolves the 'req.json is not a function' error in production.
2025-07-21 21:11:13 -05:00
Randall Stillwell
dc95d0d76d Implement complete user authentication and admin panel system
 Features Added:
- User registration and login with JWT authentication
- Role-based access control (user/admin)
- Comprehensive admin panel with user management
- Password hashing with bcrypt
- Session management and token storage
- Protected routes and public routes
- Modern login/register forms with validation

🗄️ Database Schema:
- Users table with profile information
- Roles and permissions system
- User-role junction tables
- Session management tables
- Database triggers and indexes

🎨 UI/UX Improvements:
- Updated navigation with user menu
- Admin badge and access controls
- Responsive authentication forms
- Loading states and error handling
- Role-based UI elements

🔧 API Endpoints:
- /api/auth/login - User authentication
- /api/auth/register - User registration
- /api/admin/users - User management (admin only)
- /api/setup-auth - Database schema setup

🚀 Admin Panel Features:
- User listing with search and pagination
- Role assignment (user/admin)
- User activation/deactivation
- System dashboard with stats
- Card management placeholder
- Real-time user management
2025-07-21 21:06:38 -05:00