Commit Graph

65 Commits

Author SHA1 Message Date
c0358d79d7 Fix Docker build and Next.js metadata configuration
- Move themeColor and viewport to separate viewport export in layout.tsx
- Improve Docker build process with npm ci and proper dependency handling
- Add Docker-friendly Next.js configuration settings
- Resolve constructor error and metadata warnings
2025-12-02 13:47:40 +00:00
ff16860d8a Revert to production build with proper cookie settings
- Production build is more stable than dev mode
- Cookie settings already fixed for HTTP
- NextAuth v5 beta works better in production mode
2025-12-02 13:31:19 +00:00
855abb98b7 Re-add redirect for unauthenticated users on home page 2025-12-02 13:28:39 +00:00
b9b28ad92c Run as root in dev mode for file write permissions 2025-12-02 13:26:15 +00:00
9f25b30083 Switch to dev server in Docker 2025-12-02 13:22:38 +00:00
adb4f6b119 Set NODE_ENV to development for better NextAuth compatibility
- Avoids production build issues with NextAuth v5 beta
- Enables better error messages for debugging
- Session cookies work correctly in development mode
2025-12-02 13:21:07 +00:00
9bd4dfe0e1 Fix cookie settings for HTTP deployment
- Remove __Secure- prefix for non-HTTPS
- Set secure: false to allow cookies over HTTP
- Enables session persistence in Docker deployment
2025-12-02 13:19:30 +00:00
f3d9ccde56 Remove manual redirect from home page - let middleware handle auth
- Middleware already handles authentication redirects
- Prevents error boundary from catching redirect errors
- Cleaner separation of concerns
2025-12-02 13:17:12 +00:00
ce7021e3fa Use npm install instead of npm ci for deployment flexibility 2025-12-02 13:14:46 +00:00
d677fcb9b5 Fix Docker file copying for standalone build
- Add @prisma client to copied files
- Set proper ownership for nextjs user
- Ensures all required files are available at runtime
2025-12-02 13:11:27 +00:00
b1705fa6da Simplify port mapping: expose 3500 externally, use 3000 internally
- Map host port 3500 to container port 3000
- Keep Next.js on default port 3000 inside container
- Simplifies auth configuration
2025-12-02 13:06:24 +00:00
a084853b6c Add AUTH_URL for NextAuth v5 compatibility
- NextAuth v5 uses AUTH_URL instead of NEXTAUTH_URL
- Keep both for backward compatibility
- Fixes UntrustedHost error
2025-12-02 13:02:10 +00:00
39401a3fa2 Update package-lock.json 2025-12-02 13:00:06 +00:00
899ba97457 Explicitly set trustHost in NextAuth initialization 2025-12-02 12:56:24 +00:00
1c0e0a097e Add AUTH_TRUST_HOST to build environment 2025-12-02 12:52:53 +00:00
fc06003701 Allow .env file in Docker build for private repo 2025-12-02 12:48:43 +00:00
8c9e1a76d1 Fix Prisma client generation for correct platform
- Skip Prisma postinstall during npm ci with --ignore-scripts
- Generate Prisma client explicitly in builder stage
- Ensures correct binary for Debian/Linux platform
2025-12-02 12:46:31 +00:00
92401c5324 Fix home page redirect for unauthenticated users
- Check session before calling getLists()
- Redirect to login page if not authenticated
- Prevents server component render error in production
2025-12-02 12:40:15 +00:00
c51bc28d67 Add AUTH_TRUST_HOST environment variable for Docker
- Set AUTH_TRUST_HOST=true in .env and docker-compose.yml
- Ensures NextAuth trusts all hosts in Docker environment
- Fixes UntrustedHost error
2025-12-02 12:35:23 +00:00
f1cbd88761 Switch to Debian-based Node image for Prisma compatibility
- Change from node:20-alpine to node:20-slim
- Fixes OpenSSL library compatibility issues with Prisma
- Debian has better support for Prisma's binary engines
2025-12-02 12:32:23 +00:00
9ebb2786b3 Fix Prisma OpenSSL compatibility for Alpine Docker
- Add openssl package to all Docker build stages
- Ensures Prisma engine works on Alpine Linux ARM64
- Fixes libssl.so.1.1 missing library error
2025-12-02 12:28:40 +00:00
86ef3c41d5 Fix NextAuth trusted host for Docker deployment
- Add trustHost: true to auth.config.ts
- Remove obsolete version field from docker-compose.yml
2025-12-02 12:15:08 +00:00
c5182e3b99 Update .env with DB credentials and port 3500 2025-12-02 10:14:48 +00:00
37e0620caf Include .env in repo for private deployment 2025-12-02 10:10:37 +00:00
0d26087049 Add Docker configuration for port 3500
- Add Dockerfile with multi-stage build for production
- Add docker-compose.yml for easy deployment
- Add .dockerignore to exclude unnecessary files
- Add DOCKER_SETUP.md with comprehensive setup guide
- Update next.config.js to enable standalone output mode
- Configure app to run on port 3500
- Keep MySQL server external to Docker
2025-12-02 10:09:13 +00:00
b2a59eecf1 feat: implement real-time list synchronization
- Add useRealtimeSync hook for polling server updates every 3 seconds
- Create API endpoint to check last updated timestamp for lists
- Integrate real-time sync into ListDetailView component
- Automatically refresh when other users make changes to shared lists
- Poll on interval and when page becomes visible again
2025-12-02 10:06:49 +00:00
11c4411f68 fix: Resolve Prisma Edge Runtime error in middleware
- Move all auth configuration to auth.config.ts to avoid Prisma imports in Edge Runtime
- Update middleware to use NextAuth with edge-compatible config
- Consolidate session, cookies, and callback configuration in auth.config.ts
- Update auth.ts to extend authConfig and only add Prisma-dependent providers
- This fixes the 'PrismaClient is not configured to run in Edge Runtime' error

The middleware now properly works with NextAuth v5 beta without trying to load Prisma in the Edge Runtime.
2025-12-02 01:38:26 +00:00
0e609af924 feat: Update PWA service worker for authentication
- Add authentication pages to static cache (/auth/login, /auth/register, /auth/error)
- Implement special handling for authentication API requests (network-only with offline error)
- Add authentication page caching strategy (cache-first with network fallback)
- Prevent caching of authentication errors (401, 403)
- Enhance offline page with online detection and auto-redirect
- Add authentication notice to offline page
- Update cache version to v2 for proper invalidation
- Create PWA_AUTH_GUIDE.md documentation

Task: 19. Update PWA service worker for authentication
Requirements: 4.4
2025-12-02 01:34:28 +00:00
534796edd7 feat: implement security enhancements (task 17)
- Add rate limiting for login, registration, and invitations
- Implement CSRF protection with SameSite cookies and security headers
- Configure secure session cookies with httpOnly and secure flags
- Enhance input sanitization for XSS and injection prevention
- Add comprehensive security tests (41 tests passing)
- Document security enhancements in SECURITY_ENHANCEMENTS.md

Requirements: 9.3, 9.4, 9.5
2025-12-02 01:29:35 +00:00
2ce89e7c6c feat: implement data migration for existing lists
- Created migration-actions.ts with server actions for claiming lists
- Added ClaimListsModal component for UI during registration
- Integrated claim modal into RegisterForm
- Created anonymous-lists.ts utilities for tracking lists in localStorage
- Added migrate-lists.ts script for deployment migration
- Created comprehensive MIGRATION_GUIDE.md documentation
- Added migration tests with 100% pass rate
- Updated package.json with db:migrate script
- Added tsx as dev dependency for running migration scripts

Requirements: 10.2, 10.3, 10.4, 10.5
- Users can claim existing lists on first registration
- All list data is preserved during migration
- All lists have an owner after migration
- Migrated lists appear in user's account
2025-12-02 01:20:35 +00:00
54612a4782 feat: update components for multi-user support
- Add sharing indicator to ListCard showing collaborator count
- Add permission badge and share button to ListDetailView
- Disable editing in ItemForm for viewers with visual feedback
- Add permission checks to item detail and edit pages
- Hide edit/delete buttons for viewers on item detail page
- Pass permission and collaborator data through component hierarchy
- Update navigation to include profile and invitations links (already done in previous tasks)

Implements task 15 from user-auth-and-sharing spec
2025-12-02 01:14:21 +00:00
85c8a1650b Implement profile management (task 14)
- Add updateProfile and updatePassword server actions
- Add getUserProfile function with sensitive data protection
- Create ProfileForm component for name and email updates
- Create PasswordChangeForm component with current password verification
- Create profile page at /profile with all profile management features
- Add profile and invitations navigation links to main page
- Implement email uniqueness validation
- Implement password hashing on password change

Requirements: 7.1, 7.2, 7.3, 7.4, 7.5
2025-12-02 01:06:21 +00:00
b102e86b33 feat: create sharing UI components (task 13)
- Add PermissionBadge component to display owner/editor/viewer roles
- Add InvitationCard component for accepting/declining invitations
- Add CollaboratorList component to manage list collaborators
- Add ShareListModal component for inviting users and viewing access
- Add invitations page to view and manage pending invitations

Requirements: 5.1, 5.4, 8.1, 8.2
2025-12-02 01:02:33 +00:00
7464620668 Complete task 12: Implement collaborator management
- Verified getCollaborators server action (Requirement 5.4)
- Verified updateCollaboratorPermission server action (Requirement 6.5)
- Verified removeCollaborator server action (Requirement 5.5)
- Added permission level enforcement throughout (Requirement 6.1)
- Created comprehensive test suite for collaborator management
- All tests passing (6/6 tests)
2025-12-02 01:00:03 +00:00
b73f761308 Implement invitation system with server actions
- Add inviteUserToList: Create invitations with email validation and expiration
- Add getInvitations: Retrieve pending invitations for current user
- Add acceptInvitation: Accept invitation and create collaborator record
- Add declineInvitation: Decline and remove invitation
- Add getCollaborators: List all collaborators for a list
- Add updateCollaboratorPermission: Change collaborator permission level
- Add removeCollaborator: Revoke collaborator access
- Include proper authorization checks and error handling
- Add invitation expiration logic (7 days)
- Implement transaction for atomic invitation acceptance

Requirements: 5.1, 5.2, 5.3, 8.1, 8.5
2025-12-02 00:57:50 +00:00
0e60c91b98 Complete task 10: Update item operations for access control
- All item operations (createItem, updateItem, deleteItem, toggleItem) now enforce access control
- Editor vs viewer permissions properly enforced (only owner/editor can modify)
- Item queries (searchItems, getItemsByFilter, getItem) filter by list access
- Validates Requirements 6.2, 6.3, and 9.2
2025-12-02 00:54:55 +00:00
a8962247fb Implement permission utilities (task 9)
- Created lib/permissions.ts with four utility functions:
  - canAccessList: Check if user can view a list
  - canEditList: Check if user can edit a list or its items
  - canDeleteList: Check if user can delete a list (owner only)
  - getPermission: Get user's permission level for a list
- Added comprehensive unit tests in lib/__tests__/permissions.test.ts
- All 24 tests passing
- Validates Requirements 4.3, 6.2, 6.3
2025-12-02 00:52:48 +00:00
0bb293e101 feat: implement list ownership and access control
- Modified createList to assign ownerId to authenticated user
- Updated getLists to filter by user access (owner or collaborator)
- Added ownership checks to updateList (owner or editor can update)
- Added ownership checks to deleteList (only owner can delete)
- Implemented access control for all item operations (create, update, delete, toggle)
- Updated getItem, searchItems, and getItemsByFilter to enforce access control
- Added dynamic rendering to pages that use authentication
- Cascade deletion already handled by database schema (onDelete: Cascade)

Requirements: 4.1, 4.2, 4.3, 4.5
2025-12-02 00:48:47 +00:00
2ebda95207 feat: implement route protection middleware for authentication
- Created Next.js middleware for authentication checks
- Protected main routes (/, /list/*, /profile/*, /invitations/*)
- Redirect unauthenticated users to login with callback URL
- Handle session validation and expiration
- Allow access to auth pages for unauthenticated users
- Redirect authenticated users away from login/register pages
- Added comprehensive middleware tests
- Validates Requirements 3.3, 3.5

Task: 7. Implement route protection middleware
2025-12-02 00:43:30 +00:00
d4a5232e71 feat: implement authentication UI components
- Add LoginForm component with email/password validation
- Add RegisterForm component with password confirmation
- Create login page at /auth/login
- Create register page at /auth/register
- Create authentication error page at /auth/error
- Add loading states and error handling
- Implement inline validation with user feedback
- Follow existing component patterns from ListForm

Implements task 6 from user-auth-and-sharing spec
Requirements: 1.1, 2.1
2025-12-02 00:42:04 +00:00
895ceba55f Implement session management (Task 5)
- Configure JWT session strategy with 30-day expiration
- Implement session validation middleware for route protection
- Create logout functionality with session termination
- Handle session expiration automatically via JWT
- Add session helper functions (getCurrentSession, isAuthenticated)
- Protect routes: /, /list/*, /profile/*, /invitations/*
- Redirect unauthenticated users to login with callback URL
- Requirements: 2.4, 2.5, 3.1, 3.2, 3.4
2025-12-02 00:39:04 +00:00
211ed50503 Implement authentication functionality with login server action
- Created loginUser server action with credential validation
- Implemented password verification using bcrypt (via NextAuth authorize)
- Session creation on successful login handled by NextAuth
- Invalid credentials handled with appropriate error messages
- Added comprehensive unit tests for login functionality
- All tests passing (11/11)

Requirements: 2.1, 2.2
2025-12-02 00:36:03 +00:00
70121982a0 feat: implement user registration functionality
- Created registerUser server action with email/password validation
- Implemented password hashing with bcrypt (10 rounds)
- Added email uniqueness check to prevent duplicate registrations
- Created session after successful registration using NextAuth
- Added comprehensive validation for email format and password length (min 8 chars)
- Added email and password validation utilities to lib/validation.ts
- Removed PrismaAdapter from auth.ts (using JWT sessions only)
- Added vitest testing framework and configuration
- Created comprehensive unit tests for registration functionality
- All tests passing (6/6)

Requirements covered: 1.1, 1.2, 1.3, 1.4, 1.5
2025-12-02 00:03:23 +00:00
174a6601b2 feat: update database schema for multi-user support
- Add User model with email, passwordHash, and name fields
- Add Collaborator model for list sharing with permission levels
- Add Invitation model for sharing invitations with status tracking
- Add ownerId field to List model with cascade deletion
- Add necessary indexes for performance optimization
- Implements Requirements 1.1, 4.1, 5.1
2025-12-01 23:58:20 +00:00
2c3b66b085 feat: set up authentication infrastructure with NextAuth.js v5
- Install next-auth@beta, bcryptjs, zod, and @auth/prisma-adapter
- Create auth.ts with credentials provider and JWT session strategy
- Create auth.config.ts for edge-compatible middleware configuration
- Add NextAuth type extensions for session and JWT
- Create API route handler for authentication
- Configure environment variables for NextAuth
- Add AUTH_SETUP.md documentation

Task: 1. Set up authentication infrastructure
Requirements: 1.1, 2.1
2025-12-01 23:56:45 +00:00
b3c7f92877 Complete task 19: Final checkpoint - All tests pass 2025-12-01 21:34:08 +00:00
87f91ecbe0 feat: implement performance optimizations
- Add database indexes for frequently queried fields (listId, completed, priority, dueDate, createdAt)
- Add compound indexes for common query patterns (listId+completed, listId+priority)
- Implement pagination support in getItemsByFilter with configurable page size (default 50)
- Optimize components with React.memo (ItemCard, ListCard, FilterPanel, SearchBar, SearchResults, EmptyState)
- Configure Next.js for better bundle optimization:
  - Enable optimizePackageImports for lucide-react
  - Enable SWC minification
  - Remove console logs in production (except errors/warnings)
  - Optimize images with AVIF/WebP formats
  - Enable compression
  - Disable production source maps for smaller bundles
- Loading states already implemented to prevent layout shift

Task 18 complete - all performance optimizations implemented
2025-12-01 21:29:50 +00:00
796bde22e7 feat: Add comprehensive input validation
- Created lib/validation.ts with validation utilities for all form inputs
- Added validation for list titles, item titles, colors, dates, tags, descriptions, and notes
- Implemented inline validation with real-time error feedback in ListForm
- Enhanced ItemForm with comprehensive validation for all fields
- Updated InlineItemCreate with validation
- Added input sanitization to prevent XSS attacks
- Updated server actions to use validation utilities
- Added maxLength attributes to prevent excessive input
- Improved accessibility with aria-invalid and aria-describedby attributes
- Added visual feedback for validation errors with red borders
- Validates Requirements 1.1 and 2.1
2025-12-01 21:26:26 +00:00
12ce70e495 Implement comprehensive error handling
- Add try-catch blocks to all server actions with retry logic
- Implement exponential backoff retry mechanism for database operations
- Add input validation to all server actions
- Create ErrorBoundary component for React error handling
- Add page-level error handlers (error.tsx, global-error.tsx)
- Add route-specific error pages for list and item routes
- Enhance database connection with graceful error handling
- Add user-friendly error messages throughout the application
- Implement proper error logging for debugging

Task: 16. Implement error handling
Requirements: All (error handling is cross-cutting)
2025-12-01 21:18:57 +00:00
e51e88fddd feat: Add visual feedback and polish (Task 15)
- Implement toast notification system for success/error messages
- Add loading states with skeleton loaders for async operations
- Create smooth CSS transitions and animations
- Enhance empty states with EmptyState component
- Add loading.tsx files for Next.js loading states
- Integrate toast notifications across all CRUD operations
- Add fade-in and scale-in animations for better UX
- Improve visual feedback for user actions
2025-12-01 21:14:14 +00:00