Files
yara724api/src/auth/dto/user/login.dto.ts

73 lines
1.6 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator";
import { UserModel } from "src/users/entities/schema/user.schema";
export class UserLoginDto {
@ApiProperty({
example: "09226187419",
type: "string",
description: "Mobile number (username for OTP login)",
})
@IsString()
@IsNotEmpty()
@MaxLength(20)
mobile: string;
@ApiPropertyOptional({
example: "65f0c7f0c3f8a2a7c8b3d001",
type: "string",
description: "Raw token from linked SMS URL (?token=...).",
})
@IsOptional()
@IsString()
@MaxLength(128)
linkToken?: string;
@ApiPropertyOptional({
example: "FIRST",
type: "string",
description: "Optional route/context hint for linked SMS login.",
})
@IsOptional()
@IsString()
@MaxLength(64)
linkContext?: string;
}
export class LoginDtoRs extends UserModel {
@ApiProperty({ type: "string" })
message: string;
@ApiProperty({
example: "09226187419",
type: "string",
description: "User login dto",
})
tokens: { token: string; rfToken: string };
@ApiProperty({
example: "09226187419",
type: "string",
description: "User login dto",
})
userId: string;
@ApiProperty({
example: "09226187419",
type: "string",
description: "User login dto",
})
firstName: string;
lastName: string;
username: string;
mobile: string;
nationalCode: string;
constructor(loginData, message: string = "") {
super();
this.mobile = loginData.mobile;
this.message = message;
}
}