implement auth login and register with MongoDB

- Add AuthController login/register endpoints with error handling
- Implement AuthService with password validation and user creation
- Add MongoUserRepository with findByEmail and create methods
- Implement password hashing with bcrypt
- Add dotenv for environment variable support
- Add Docker Compose setup for MongoDB + Mongo Express
- Stub AuthMiddleware with fake user for testing
- Update CLAUDE.md with implementation status
This commit is contained in:
2026-01-03 16:47:11 +01:00
parent 9cc6d17607
commit 105a9a4980
12 changed files with 177 additions and 10 deletions

View File

@@ -198,9 +198,44 @@ The repository pattern allows swapping databases:
- Multiple calendars
- CalDAV synchronization with external services
## Development Environment
### MongoDB (Docker)
```bash
cd apps/server/docker/mongo
docker compose up -d # Start MongoDB + Mongo Express
docker compose down # Stop services
```
- MongoDB: `localhost:27017` (root/mongoose)
- Mongo Express UI: `localhost:8081` (admin/admin)
### Environment Variables
Server requires `.env` file in `apps/server/`:
```
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=1h
MONGODB_URI=mongodb://root:mongoose@localhost:27017/calchat?authSource=admin
```
## Current Implementation Status
**Backend:** Skeleton complete - all files exist with `throw new Error('Not implemented')` placeholders. Ready for step-by-step implementation.
**Backend:**
- **Implemented:**
- `AuthController`: login(), register() with error handling
- `AuthService`: login(), register() with password validation
- `MongoUserRepository`: findByEmail(), create()
- `utils/password`: hash(), compare() using bcrypt
- `utils/jwt`: signToken() (verifyToken() pending)
- `dotenv` integration for environment variables
- **Stubbed (TODO):**
- `AuthMiddleware.authenticate()`: Currently uses fake user for testing
- `AuthController`: refresh(), logout()
- `AuthService`: refreshToken()
- All Chat and Event functionality
- **Not started:**
- `ChatController`, `ChatService`, `MongoChatRepository`
- `EventController`, `EventService`, `MongoEventRepository`
- `ClaudeAdapter` (AI integration)
**Shared:** Types and DTOs defined and exported.
@@ -216,6 +251,7 @@ The repository pattern allows swapping databases:
## Documentation
Detailed architecture diagrams are in `docs/`:
- `api-routes.md` - API endpoint overview (German)
- `technisches_brainstorm.tex` - Technical concept document (German)
- `architecture-class-diagram.puml` - Backend class diagram
- `frontend-class-diagram.puml` - Frontend class diagram