From 1054ac6053c09f843a44081e1adbf80992e13507 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Oct 2024 14:20:31 +0300 Subject: [PATCH] fixed forgot password --- src/auth/controllers/user-auth.controller.ts | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) 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()