feat( auth ): make email optional in signup/login

This commit is contained in:
Abubeker Yasin
2026-07-10 13:38:53 +03:00
parent 4705f5c478
commit 8321c697ec
4 changed files with 60 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
import { IsEmail, IsString, ValidateNested } from 'class-validator';
import { IsEmail, IsNotEmpty, IsString, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';
@@ -13,8 +13,13 @@ export class NameDto {
}
export class RegisterDto {
@ApiProperty({ example: 'kelemu@email.com' })
@IsEmail()
// Accepts an email OR a phone number. When a passenger signs up without an email,
// the portal passes the phone number here (and as `username`) — the IAM only requires
// a non-empty string, so a phone value is a valid account identifier. Kept as
// @IsString/@IsNotEmpty (not @IsEmail) so that phone-as-email passes the ValidationPipe.
@ApiProperty({ example: 'kelemu@email.com', description: 'Email or, when the user has no email, their phone number' })
@IsString()
@IsNotEmpty()
email: string;
@ApiProperty({ example: 'kelemu.ketsela' })
@@ -42,8 +47,12 @@ export class ResendRegistrationCodeDto {
}
export class LoginDto {
@ApiProperty({ example: 'kelemu@email.com' })
@IsEmail()
// Accepts an email OR a phone number in the same field. Passengers who registered
// without an email log in with their phone number, which the IAM matches. Kept as
// @IsString/@IsNotEmpty (not @IsEmail) so a phone value passes the ValidationPipe.
@ApiProperty({ example: 'kelemu@email.com', description: 'Email or phone number' })
@IsString()
@IsNotEmpty()
email: string;
@ApiProperty({ example: 'password123', format: 'password' })