forked from Yara724/api
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { ApiProperty } from "@nestjs/swagger";
|
|
import { IsNotEmpty, IsString, MaxLength } from "class-validator";
|
|
import { RoleEnum } from "src/Types&Enums/role.enum";
|
|
|
|
export class LoginActorDto {
|
|
@ApiProperty({ example: RoleEnum, type: "array", description: "LOGIN_DTO" })
|
|
role: RoleEnum[];
|
|
|
|
@ApiProperty({})
|
|
username: string;
|
|
|
|
@ApiProperty({})
|
|
password: string;
|
|
|
|
@ApiProperty({
|
|
example: "f47ac10b-58cc-4372-a567-0e02b2c3d479",
|
|
description: "Captcha id from GET /actor/captcha.",
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(64)
|
|
captchaId: string;
|
|
|
|
@ApiProperty({
|
|
example: "a7bx2",
|
|
description: "Characters shown in the captcha image.",
|
|
})
|
|
@IsString()
|
|
@IsNotEmpty()
|
|
@MaxLength(16)
|
|
captcha: string;
|
|
}
|
|
|
|
export class LoginActorDtoRs extends LoginActorDto {
|
|
private readonly userId;
|
|
constructor(userData) {
|
|
super();
|
|
this.userId = userData._id;
|
|
this.role = userData.role;
|
|
this.username = userData.email;
|
|
this.clientKey = userData.clientKey;
|
|
this.token = userData.token;
|
|
this.refreshToken = userData.refreshToken;
|
|
}
|
|
|
|
@ApiProperty({ type: "string", description: "LOGIN_DTO_RS" })
|
|
fullName: string;
|
|
|
|
@ApiProperty({ type: "string", description: "LOGIN_DTO_RS" })
|
|
role: RoleEnum[];
|
|
|
|
@ApiProperty({ type: "string", description: "LOGIN_DTO_RS" })
|
|
token: string;
|
|
|
|
@ApiProperty({ type: "string", description: "LOGIN_DTO_RS" })
|
|
refreshToken: string;
|
|
|
|
@ApiProperty({ type: "string", description: "LOGIN_DTO_RS" })
|
|
clientKey: string;
|
|
}
|