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