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:
@@ -5,11 +5,21 @@ export class AuthController {
|
||||
constructor(private authService: AuthService) {}
|
||||
|
||||
async login(req: Request, res: Response): Promise<void> {
|
||||
throw new Error('Not implemented');
|
||||
try {
|
||||
const result = await this.authService.login(req.body);
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(401).json({ error: (error as Error).message });
|
||||
}
|
||||
}
|
||||
|
||||
async register(req: Request, res: Response): Promise<void> {
|
||||
throw new Error('Not implemented');
|
||||
try {
|
||||
const result = await this.authService.register(req.body);
|
||||
res.status(201).json(result);
|
||||
} catch (error) {
|
||||
res.status(400).json({ error: (error as Error).message });
|
||||
}
|
||||
}
|
||||
|
||||
async refresh(req: Request, res: Response): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user