diff --git a/SerpentRace_Backend/src/Api/routers/userRouter.ts b/SerpentRace_Backend/src/Api/routers/userRouter.ts index 6691c60c..db8c1625 100644 --- a/SerpentRace_Backend/src/Api/routers/userRouter.ts +++ b/SerpentRace_Backend/src/Api/routers/userRouter.ts @@ -77,10 +77,12 @@ userRouter.post('/create', email: req.body.email }); - const result = await container.createUserCommandHandler.execute(req.body); - - logRequest('User created successfully', req, res, { - username: result.username + const language = req.header('Accept-Language') || 'en'; + + const result = await container.createUserCommandHandler.execute({ ...req.body, language }); + + logRequest('User created successfully', req, res, { + username: result.username }); res.status(201).json(result); @@ -268,10 +270,11 @@ userRouter.post('/forgot-password', async (req, res) => { try { const { email } = req.body; + const language = req.header('Accept-Language') || 'en'; logRequest('Forgot password endpoint accessed', req, res, { email }); - const result = await container.requestPasswordResetCommandHandler.execute({ email }); + const result = await container.requestPasswordResetCommandHandler.execute({ language, email }); if (result) { logAuth('Password reset request successful', undefined, { email }, req, res); diff --git a/SerpentRace_Backend/src/Application/DTOs/DeckDto.ts b/SerpentRace_Backend/src/Application/DTOs/DeckDto.ts index 5c1f1421..9c89a59a 100644 --- a/SerpentRace_Backend/src/Application/DTOs/DeckDto.ts +++ b/SerpentRace_Backend/src/Application/DTOs/DeckDto.ts @@ -15,7 +15,7 @@ export interface ShortDeckDto { type: number; playedNumber: number; ctype: number; - cardsCount: number; + cardCount: number; creator: string; creationdate: Date; } diff --git a/SerpentRace_Backend/src/Application/DTOs/Mappers/DeckMapper.ts b/SerpentRace_Backend/src/Application/DTOs/Mappers/DeckMapper.ts index a2d8e420..b98991aa 100644 --- a/SerpentRace_Backend/src/Application/DTOs/Mappers/DeckMapper.ts +++ b/SerpentRace_Backend/src/Application/DTOs/Mappers/DeckMapper.ts @@ -10,7 +10,7 @@ export class DeckMapper { type: deck.type, playedNumber: deck.playedNumber, ctype: deck.ctype, - cardsCount: deck.cards.length, + cardCount: deck.cards.length, creator: deck.user?.username || 'Unknown', creationdate: deck.creationdate }; @@ -36,7 +36,7 @@ export class DeckMapper { type: deck.type, playedNumber: deck.playedNumber, ctype: deck.ctype, - cardsCount: deck.cards.length, + cardCount: deck.cards.length, creator: deck.user?.username || 'Unknown', creationdate: deck.creationdate })); diff --git a/SerpentRace_Backend/src/Application/User/commands/CreateUserCommand.ts b/SerpentRace_Backend/src/Application/User/commands/CreateUserCommand.ts index b8bed6a0..08219c3c 100644 --- a/SerpentRace_Backend/src/Application/User/commands/CreateUserCommand.ts +++ b/SerpentRace_Backend/src/Application/User/commands/CreateUserCommand.ts @@ -7,4 +7,5 @@ export interface CreateUserCommand { code?: string; orgid?: string; phone?: string; + language: string; } diff --git a/SerpentRace_Backend/src/Application/User/commands/CreateUserCommandHandler.ts b/SerpentRace_Backend/src/Application/User/commands/CreateUserCommandHandler.ts index d359c6ce..51bae307 100644 --- a/SerpentRace_Backend/src/Application/User/commands/CreateUserCommandHandler.ts +++ b/SerpentRace_Backend/src/Application/User/commands/CreateUserCommandHandler.ts @@ -43,7 +43,7 @@ export class CreateUserCommandHandler { const created = await this.userRepo.create(user); // Send verification email (non-blocking) - this.sendVerificationEmailAsync(created, verificationTokenData.token); + this.sendVerificationEmailAsync(cmd.language, created, verificationTokenData.token); return UserMapper.toShortDto(created); } catch (error) { @@ -67,16 +67,24 @@ export class CreateUserCommandHandler { } } - private async sendVerificationEmailAsync(user: UserAggregate, token: string): Promise { + private async sendVerificationEmailAsync(language: string, user: UserAggregate, token: string): Promise { try { const baseUrl = process.env.FRONTEND_URL || 'http://localhost:5173'; const verificationUrl = TokenService.generateVerificationUrl(baseUrl, token); + var lang: 'en' | 'hu' | 'de' = 'en'; + if (language) { + lang = language.toLowerCase() as 'en' | 'hu' | 'de'; + } + + + const emailSent = await this.emailService.sendVerificationEmail( user.email, `${user.fname} ${user.lname}`, token, - verificationUrl + verificationUrl, + lang ); if (!emailSent) { diff --git a/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommand.ts b/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommand.ts index ed314d11..809b9a0a 100644 --- a/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommand.ts +++ b/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommand.ts @@ -1,3 +1,4 @@ export interface RequestPasswordResetCommand { + language: string; email: string; } diff --git a/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommandHandler.ts b/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommandHandler.ts index e3d667f2..dca3f536 100644 --- a/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommandHandler.ts +++ b/SerpentRace_Backend/src/Application/User/commands/RequestPasswordResetCommandHandler.ts @@ -38,14 +38,21 @@ export class RequestPasswordResetCommandHandler { // Send password reset email try { - const baseUrl = process.env.APP_BASE_URL || 'http://localhost:3000'; + const baseUrl = process.env.FRONTEND_URL || 'http://localhost:5173'; const resetUrl = TokenService.generatePasswordResetUrl(baseUrl, resetTokenData.token); - + + var lang: 'en' | 'hu' | 'de' = 'en'; + if (cmd.language) { + lang = cmd.language.toLowerCase() as 'en' | 'hu' | 'de'; + } + + const emailSent = await this.emailService.sendPasswordResetEmail( user.email, `${user.fname} ${user.lname}`, resetTokenData.token, - resetUrl + resetUrl, + lang ); if (!emailSent) {