mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 09:24:54 +00:00
fixed forgot password
This commit is contained in:
@ -16,6 +16,7 @@ import { ForgetPasswordDto, UserOtpDto, VerifyOtpDto } from '../dtos';
|
|||||||
import { RefreshTokenGuard } from '@app/common/guards/jwt-refresh.auth.guard';
|
import { RefreshTokenGuard } from '@app/common/guards/jwt-refresh.auth.guard';
|
||||||
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
import { SuperAdminRoleGuard } from 'src/guards/super.admin.role.guard';
|
||||||
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
|
||||||
|
import { OtpType } from '@app/common/constants/otp-type.enum';
|
||||||
|
|
||||||
@Controller({
|
@Controller({
|
||||||
version: EnableDisableStatusEnum.ENABLED,
|
version: EnableDisableStatusEnum.ENABLED,
|
||||||
@ -74,6 +75,11 @@ 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({
|
||||||
|
otpCode: forgetPasswordDto.otpCode,
|
||||||
|
email: forgetPasswordDto.email,
|
||||||
|
type: OtpType.PASSWORD,
|
||||||
|
});
|
||||||
await this.userAuthService.forgetPassword(forgetPasswordDto);
|
await this.userAuthService.forgetPassword(forgetPasswordDto);
|
||||||
return {
|
return {
|
||||||
statusCode: HttpStatus.OK,
|
statusCode: HttpStatus.OK,
|
||||||
|
|||||||
@ -22,4 +22,9 @@ export class ForgetPasswordDto {
|
|||||||
'password must be at least 8 characters long and include at least one uppercase letter, one lowercase letter, one numeric digit, and one special character.',
|
'password must be at least 8 characters long and include at least one uppercase letter, one lowercase letter, one numeric digit, and one special character.',
|
||||||
})
|
})
|
||||||
public password: string;
|
public password: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
public otpCode: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import * as argon2 from 'argon2';
|
|||||||
import { differenceInSeconds } from '@app/common/helper/differenceInSeconds';
|
import { differenceInSeconds } from '@app/common/helper/differenceInSeconds';
|
||||||
import { LessThan, MoreThan } from 'typeorm';
|
import { LessThan, MoreThan } from 'typeorm';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { UUID } from 'typeorm/driver/mongodb/bson.typings';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class UserAuthService {
|
export class UserAuthService {
|
||||||
|
|||||||
Reference in New Issue
Block a user