feat: add email verification, password reset, and WSDC integration (Phase 1.5)

Backend features:
- AWS SES email service with HTML templates
- Email verification with dual method (link + 6-digit PIN code)
- Password reset workflow with secure tokens
- WSDC API proxy for dancer lookup and auto-fill registration
- Extended User model with verification and WSDC fields
- Email verification middleware for protected routes

Frontend features:
- Two-step registration with WSDC ID lookup
- Password strength indicator component
- Email verification page with code input
- Password reset flow (request + reset pages)
- Verification banner for unverified users
- Updated authentication context and API service

Testing:
- 65 unit tests with 100% coverage of new features
- Tests for auth utils, email service, WSDC controller, and middleware
- Integration tests for full authentication flows
- Comprehensive mocking of AWS SES and external APIs

Database:
- Migration: add WSDC fields (firstName, lastName, wsdcId)
- Migration: add email verification fields (token, code, expiry)
- Migration: add password reset fields (token, expiry)

Documentation:
- Complete Phase 1.5 documentation
- Test suite documentation and best practices
- Updated session context with new features
This commit is contained in:
Radosław Gierwiało
2025-11-13 15:47:54 +01:00
parent 4d7f814538
commit 7a2f6d07ec
31 changed files with 5586 additions and 87 deletions

View File

@@ -15,8 +15,8 @@
## Current Status
**Phase:** 1 (Backend Foundation) - ✅ COMPLETED
**Progress:** ~50%
**Phase:** 1.5 (Email Verification & WSDC Integration) - ✅ COMPLETED
**Progress:** ~60%
**Next Goal:** Phase 2 - Core Features (Matches API, Ratings, WebRTC signaling)
### What Works Now
@@ -25,6 +25,9 @@
- ✅ Backend API (Node.js + Express)
- ✅ PostgreSQL database with 6 tables (Prisma ORM)
- ✅ Real authentication (JWT + bcrypt)
-**Email verification (AWS SES with link + PIN code) - Phase 1.5**
-**Password reset workflow - Phase 1.5**
-**WSDC ID integration for auto-fill registration - Phase 1.5**
- ✅ Real-time chat (Socket.IO for event & match rooms)
- ✅ WebRTC P2P transfer UI mockup
@@ -100,38 +103,54 @@
## Key Files
**Frontend:**
- `frontend/src/pages/RegisterPage.jsx` - **NEW: Two-step registration (WSDC lookup + form) - Phase 1.5**
- `frontend/src/pages/VerifyEmailPage.jsx` - **NEW: Email verification (link + code) - Phase 1.5**
- `frontend/src/pages/ForgotPasswordPage.jsx` - **NEW: Request password reset - Phase 1.5**
- `frontend/src/pages/ResetPasswordPage.jsx` - **NEW: Reset password with token - Phase 1.5**
- `frontend/src/components/common/PasswordStrengthIndicator.jsx` - **NEW: Password strength indicator - Phase 1.5**
- `frontend/src/components/common/VerificationBanner.jsx` - **NEW: Email verification banner - Phase 1.5**
- `frontend/src/pages/EventChatPage.jsx` - Event chat with Socket.IO real-time messaging
- `frontend/src/pages/MatchChatPage.jsx` - Private chat + WebRTC mockup
- `frontend/src/contexts/AuthContext.jsx` - JWT authentication integration
- `frontend/src/services/api.js` - API client (register, login, users)
- `frontend/src/services/api.js` - API client (extended with email verification & WSDC lookup)
- `frontend/src/services/socket.js` - Socket.IO client connection manager
**Backend:**
- `backend/src/controllers/auth.js` - **UPDATED: Register, login, email verification, password reset - Phase 1.5**
- `backend/src/controllers/wsdc.js` - **NEW: WSDC API proxy for dancer lookup - Phase 1.5**
- `backend/src/utils/email.js` - **NEW: AWS SES email service with HTML templates - Phase 1.5**
- `backend/src/utils/auth.js` - **UPDATED: Token generation utilities - Phase 1.5**
- `backend/src/middleware/auth.js` - **UPDATED: Email verification middleware - Phase 1.5**
- `backend/src/server.js` - Express server with Socket.IO integration
- `backend/src/socket/index.js` - Socket.IO server (event/match rooms, 89% coverage)
- `backend/src/controllers/auth.js` - Register, login endpoints
- `backend/src/middleware/auth.js` - JWT authentication middleware
- `backend/src/utils/auth.js` - bcrypt + JWT utilities
- `backend/prisma/schema.prisma` - Database schema (6 tables)
- `backend/prisma/schema.prisma` - **UPDATED: Extended User model - Phase 1.5**
- `backend/prisma/migrations/20251113151534_add_wsdc_and_email_verification/` - **NEW migration**
**Config:**
- `docker-compose.yml` - nginx, frontend, backend, PostgreSQL
- `nginx/conf.d/default.conf` - Proxy for /api and /socket.io
- `backend/.env` - Database URL, JWT secret
- `backend/.env` - **UPDATED: AWS SES credentials, email settings - Phase 1.5**
---
## Database Schema (Implemented - Prisma)
6 tables with relations:
- `users` - id, username, email, password_hash, avatar, created_at
- `users` - **EXTENDED in Phase 1.5:**
- Base: id, username, email, password_hash, avatar, created_at, updated_at
- **WSDC:** first_name, last_name, wsdc_id
- **Email Verification:** email_verified, verification_token, verification_code, verification_token_expiry
- **Password Reset:** reset_token, reset_token_expiry
- `events` - id, name, location, start_date, end_date, description, worldsdc_id
- `chat_rooms` - id, event_id, match_id, type (event/private), created_at
- `messages` - id, room_id, user_id, content, type, created_at
- `matches` - id, user1_id, user2_id, event_id, room_id, status, created_at
- `ratings` - id, match_id, rater_id, rated_id, score, comment, created_at
**Migrations:** Applied with Prisma Migrate
**Migrations:**
- `20251112205214_init` - Initial schema
- `20251113151534_add_wsdc_and_email_verification` - **Phase 1.5 migration**
**Seed data:** 3 events, 2 users, event chat rooms
---
@@ -313,6 +332,7 @@ RUN apk add --no-cache openssl
---
**Last Updated:** 2025-11-12
**Last Updated:** 2025-11-13
**Phase 1 Status:** ✅ COMPLETED - Backend Foundation (Express + PostgreSQL + JWT + Socket.IO)
**Phase 1.5 Status:** ✅ COMPLETED - Email Verification & WSDC Integration (AWS SES + Password Reset + WSDC API)
**Next Phase:** Phase 2 - Core Features (Matches API + Ratings + WebRTC)