Commit graph

5 commits

Author SHA1 Message Date
Randall Stillwell
299fb1916b Remove conflicting TypeScript API files
🔧 Build Fix:
- Remove .ts versions of API files that conflict with .js versions
- Keep only working JavaScript API endpoints:
  - api/auth/login.js
  - api/auth/register.js
  - api/setup-auth.js
  - api/simple.js
  - api/debug.js

This resolves the Vercel build error about conflicting file paths.
2025-07-22 06:55:09 -05:00
Randall Stillwell
45bca2873f Convert auth endpoints to working Vercel function format
🔧 API Format Fix:
- Convert register.ts to register.js using req/res pattern
- Convert login.ts to login.js using req/res pattern
- Convert setup-auth.ts to setup-auth.js using req/res pattern
- Use CommonJS require() instead of ES6 imports
- Use traditional Vercel function signature that works

 Working Format:
- export default async function handler(req, res)
- req.body for request data (auto-parsed by Vercel)
- res.status().json() for responses
- CommonJS modules with require()

This should resolve all timeout issues and make authentication work properly.
2025-07-22 06:46:09 -05:00
Randall Stillwell
0531f25cbb Add debugging tools and optimize auth endpoints
🔧 Debugging Improvements:
- Optimize setup-auth endpoint to avoid timeouts
- Add table existence checks before operations
- Simplify permission system for faster setup
- Add environment variable validation
- Create test-db endpoint for connection debugging

🚀 Performance Optimizations:
- Break down large SQL queries into smaller chunks
- Add early returns for already-setup scenarios
- Reduce permission complexity during initial setup
- Better error messages for troubleshooting

🧪 New Debug Endpoints:
- /api/test-db - Test database connectivity
- /api/setup-auth - Optimized schema setup

These changes should resolve timeout issues and provide better debugging information for authentication problems.
2025-07-21 21:39:08 -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