diff --git a/src/auth/controllers/user-auth.controller.ts b/src/auth/controllers/user-auth.controller.ts index 1bf429b..92f30bd 100644 --- a/src/auth/controllers/user-auth.controller.ts +++ b/src/auth/controllers/user-auth.controller.ts @@ -1,4 +1,5 @@ import { + BadRequestException, Body, Controller, Get, @@ -75,17 +76,24 @@ export class UserAuthController { @Post('user/forget-password') async forgetPassword(@Body() forgetPasswordDto: ForgetPasswordDto) { - await this.userAuthService.verifyOTP({ + const otpResult = await this.userAuthService.verifyOTP({ otpCode: forgetPasswordDto.otpCode, email: forgetPasswordDto.email, type: OtpType.PASSWORD, }); - await this.userAuthService.forgetPassword(forgetPasswordDto); - return { - statusCode: HttpStatus.OK, - data: {}, - message: 'Password changed successfully', - }; + if (otpResult) { + await this.userAuthService.forgetPassword(forgetPasswordDto); + return { + statusCode: HttpStatus.OK, + data: {}, + message: 'Password changed successfully', + }; + } +throw new BadRequestException({ + statusCode: HttpStatus.BAD_REQUEST, + data: {}, + message: 'Otp is incorrect', +}) } @ApiBearerAuth()