This commit is contained in:
SepehrYahyaee
2026-05-24 10:10:17 +03:30
parent 91221a6848
commit af875a4773
20 changed files with 439 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsNotEmpty, IsString, MaxLength } from "class-validator";
import { RoleEnum } from "src/Types&Enums/role.enum";
export class LoginActorDto {
@@ -10,6 +11,15 @@ export class LoginActorDto {
@ApiProperty({})
password: string;
@ApiProperty({
example: "a7bx2",
description: "Captcha text from GET /actor/captcha (same username + role).",
})
@IsString()
@IsNotEmpty()
@MaxLength(16)
captcha: string;
}
export class LoginActorDtoRs extends LoginActorDto {

View File

@@ -0,0 +1,18 @@
import { ApiProperty } from "@nestjs/swagger";
export class CaptchaResponseDto {
@ApiProperty({
description:
"SVG captcha as a data URI — use as `<img src={image} />` in the frontend. " +
"Swagger shows this as text only; paste the full string into a browser tab, " +
"or call GET /actor/captcha?format=raw to view the image directly.",
example: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iLi4u",
})
image: string;
@ApiProperty({
description: "Unix timestamp (ms) when this captcha expires.",
example: 1710000000000,
})
expiresAt: number;
}

View File

@@ -0,0 +1,33 @@
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { IsEnum, IsIn, IsNotEmpty, IsOptional, IsString, MaxLength } from "class-validator";
import { RoleEnum } from "src/Types&Enums/role.enum";
export class GetActorCaptchaQueryDto {
@ApiProperty({
example: "expert@gmail.com",
description: "Actor email / username",
})
@IsString()
@IsNotEmpty()
@MaxLength(128)
username: string;
@ApiProperty({
enum: RoleEnum,
example: RoleEnum.EXPERT,
description: "Actor role",
})
@IsEnum(RoleEnum)
role: RoleEnum;
@ApiPropertyOptional({
enum: ["json", "raw"],
default: "json",
description:
"Use `raw` to open the captcha directly in the browser (image/svg+xml). " +
"Default `json` returns `{ image, expiresAt }` for the frontend.",
})
@IsOptional()
@IsIn(["json", "raw"])
format?: "json" | "raw";
}