Akshar2325
✨ feat(super-admin-2fa): introduce two-factor authentication
add3ead
Raw
History Blame
1.24 kB
import { ApiProperty } from '@nestjs/swagger';
import {
IsEmail,
IsString,
IsNotEmpty,
IsBoolean,
IsOptional,
Length,
Matches,
} from 'class-validator';
export class EnableEmail2FADto {
@ApiProperty({
example: 'admin@streamflix.com',
description: 'Super admin email',
})
@IsEmail()
@IsNotEmpty()
email: string;
}
export class SendEmail2FACodeDto {
@ApiProperty({
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
description: 'Pending 2FA token from login',
})
@IsString()
@IsNotEmpty()
pending2faToken: string;
}
export class VerifyEmail2FADto {
@ApiProperty({
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
description: 'Pending 2FA token from login',
})
@IsString()
@IsNotEmpty()
pending2faToken: string;
@ApiProperty({ example: '123456', description: '6-digit verification code' })
@IsString()
@IsNotEmpty()
@Length(6, 6, { message: 'Code must be exactly 6 digits' })
@Matches(/^\d{6}$/, { message: 'Code must contain only digits' })
code: string;
@ApiProperty({
example: true,
description: 'Remember this device for 30 days (skip 2FA on this device)',
required: false,
})
@IsBoolean()
@IsOptional()
trustDevice?: boolean;
}