fixed forgot password

This commit is contained in:
unknown
2024-10-21 14:20:31 +03:00
parent f165e8ce3a
commit 1054ac6053

View File

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