mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 07:54:53 +00:00
fixed forgot password
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user