From d269e9efe449ef5400b077775e27742e6215496c Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Tue, 10 Jan 2023 18:50:32 -0300 Subject: [PATCH] FIX: send language on reset password email --- src/modules/auth/auth.controller.ts | 14 +++++++++----- src/modules/auth/auth.service.ts | 9 +++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index 16a9a52..2bf3915 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -29,7 +29,6 @@ import { AuthClientService } from './auth.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter'; import { RequestUser, User } from 'src/authentication/user.decorator'; -import { Metadata } from '@grpc/grpc-js'; import { AuthRefreshAccessTokenReq, AuthSignInReq, @@ -58,8 +57,7 @@ export class AuthController { @Headers('Dadosfera-Lang') language: string, ): Promise { this.logger.info('/auth - SignIn'); - const metadata = new Metadata(); - metadata.add('language', language || 'pt-br'); + const metadata = PackTheMetadata({ language: language || 'pt-br' }); return this.authClient.signIn({ username, password, totp }, metadata); } @@ -115,12 +113,18 @@ export class AuthController { @Post('reset-password') @HttpCode(HttpStatus.OK) - async resetPassword(@Body() body: AuthResetPasswordRequest) { + async resetPassword( + @Body() body: AuthResetPasswordRequest, + @Headers('dadosfera-lang') language, + ) { this.logger.info('/auth - reset-password'); + const metadata = PackTheMetadata({ + language: language, + }); const { username } = body; - return this.authClient.resetPassword({ username }); + return this.authClient.resetPassword({ username }, metadata); } @Post('verify-reset-password-code') diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index c810d66..8a69efe 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -90,10 +90,15 @@ export class AuthClientService implements OnModuleInit { ); } - async resetPassword({ username }: AuthResetPasswordRequest) { + async resetPassword( + { username }: AuthResetPasswordRequest, + metadata: Metadata, + ) { this.logger.info('resetPassword'); - return lastValueFrom(this.authService.AuthResetPassword({ username })); + return lastValueFrom( + this.authService.AuthResetPassword({ username }, metadata), + ); } async verifyResetPasswordCode({