mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 08:20:58 +00:00
feat( auth ): make email optional in signup/login
This commit is contained in:
@@ -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' })
|
||||
|
||||
Reference in New Issue
Block a user