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 {
BadRequestException,
Body,
Controller,
Get,
@ -75,11 +76,12 @@ 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,
});
if (otpResult) {
await this.userAuthService.forgetPassword(forgetPasswordDto);
return {
statusCode: HttpStatus.OK,
@ -87,6 +89,12 @@ export class UserAuthController {
message: 'Password changed successfully',
};
}
throw new BadRequestException({
statusCode: HttpStatus.BAD_REQUEST,
data: {},
message: 'Otp is incorrect',
})
}
@ApiBearerAuth()
@UseGuards(SuperAdminRoleGuard)