Akshar2325
✨ feat(super-admin-2fa): introduce two-factor authentication
add3ead
Raw
History Blame
1.06 kB
import { ApiProperty } from '@nestjs/swagger';
import {
IsEmail,
IsString,
IsNotEmpty,
IsBoolean,
IsOptional,
Length,
Matches,
} from 'class-validator';
export class VerifyRecoveryCodeDto {
@ApiProperty({
example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
description: 'Pending 2FA token from login',
})
@IsString()
@IsNotEmpty()
pending2faToken: string;
@ApiProperty({ example: 'ABCD-EFGH', description: 'Recovery code' })
@IsString()
@IsNotEmpty()
@Length(9, 9, { message: 'Recovery code must be in format XXXX-XXXX' })
@Matches(/^[A-Z0-9]{4}-[A-Z0-9]{4}$/, {
message: 'Invalid recovery code format',
})
code: string;
@ApiProperty({
example: true,
description: 'Remember this device for 30 days (skip 2FA on this device)',
required: false,
})
@IsBoolean()
@IsOptional()
trustDevice?: boolean;
}
export class RegenerateRecoveryCodesDto {
@ApiProperty({
example: 'admin@streamflix.com',
description: 'Super admin email',
})
@IsEmail()
@IsNotEmpty()
email: string;
}