diff --git a/src/auth/dtos/request/verify-user.request.dto.ts b/src/auth/dtos/request/verify-user.request.dto.ts index 94944a2..71a62ba 100644 --- a/src/auth/dtos/request/verify-user.request.dto.ts +++ b/src/auth/dtos/request/verify-user.request.dto.ts @@ -1,7 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; import { - IsDateString, - IsEmail, IsEnum, IsNotEmpty, IsNumberString, @@ -15,7 +13,7 @@ import { i18nValidationMessage as i18n } from 'nestjs-i18n'; import { COUNTRY_CODE_REGEX, PASSWORD_REGEX } from '~/auth/constants'; import { CountryIso } from '~/common/enums'; import { DEFAULT_OTP_LENGTH } from '~/common/modules/otp/constants'; -import { IsAbove18, IsValidPhoneNumber } from '~/core/decorators/validations'; +import { IsValidPhoneNumber } from '~/core/decorators/validations'; export class VerifyUserRequestDto { @ApiProperty({ example: '+962' }) @@ -39,11 +37,6 @@ export class VerifyUserRequestDto { @IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.lastName' }) }) lastName!: string; - @ApiProperty({ example: '2001-01-01' }) - @IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'customer.dateOfBirth' }) }) - @IsAbove18({ message: i18n('validation.IsAbove18', { path: 'general', property: 'customer.dateOfBirth' }) }) - dateOfBirth!: Date; - @ApiProperty({ example: 'JO' }) @IsEnum(CountryIso, { message: i18n('validation.IsEnum', { path: 'general', property: 'customer.countryOfResidence' }), @@ -51,11 +44,6 @@ export class VerifyUserRequestDto { @IsOptional() countryOfResidence: CountryIso = CountryIso.SAUDI_ARABIA; - @ApiProperty({ example: 'test@test.com' }) - @IsEmail({}, { message: i18n('validation.IsEmail', { path: 'general', property: 'auth.email' }) }) - @IsOptional() - email!: string; - @ApiProperty({ example: 'Abcd1234@' }) @Matches(PASSWORD_REGEX, { message: i18n('validation.Matches', { path: 'general', property: 'auth.password' }), diff --git a/src/auth/services/auth.service.ts b/src/auth/services/auth.service.ts index 5330bed..8347ebf 100644 --- a/src/auth/services/auth.service.ts +++ b/src/auth/services/auth.service.ts @@ -41,14 +41,6 @@ export class AuthService { ) {} async sendRegisterOtp(body: CreateUnverifiedUserRequestDto) { - if (body.email) { - const isEmailUsed = await this.userService.findUser({ email: body.email, isEmailVerified: true }); - if (isEmailUsed) { - this.logger.error(`Email ${body.email} is already used`); - throw new BadRequestException('USER.EMAIL_ALREADY_TAKEN'); - } - } - if (body.password !== body.confirmPassword) { this.logger.error('Password and confirm password do not match'); throw new BadRequestException('AUTH.PASSWORD_MISMATCH'); diff --git a/src/user/services/user.service.ts b/src/user/services/user.service.ts index 73e2e58..cc7aa12 100644 --- a/src/user/services/user.service.ts +++ b/src/user/services/user.service.ts @@ -64,14 +64,12 @@ export class UserService { this.customerService.createGuardianCustomer(userId, { firstName: body.firstName, lastName: body.lastName, - dateOfBirth: body.dateOfBirth, countryOfResidence: body.countryOfResidence, }), this.userRepository.update(userId, { isPhoneVerified: true, password: hashedPassword, salt, - ...(body.email && { email: body.email }), }), ]); } @@ -102,7 +100,6 @@ export class UserService { return this.userRepository.createUnverifiedUser({ phoneNumber: body.phoneNumber, countryCode: body.countryCode, - email: body.email, firstName: body.firstName, lastName: body.lastName, roles: [Roles.GUARDIAN],