File

src/registrar/dto/registrar-config-response.dto.ts

Description

DTO for the registrar configuration response. Excludes the password field for security and includes a flag indicating if a password is set.

Extends

OmitType( RegistrarConfigEntity, ["tenant", "tenantId", "password"] as const, )

Index

Properties
Methods

Properties

hasPassword
Type : boolean
Decorators :
@ApiProperty({description: 'Indicates whether a password is configured (actual password is never returned)', example: true})

Indicates whether a password is configured. The actual password is never returned for security reasons.

Methods

Static fromEntity
fromEntity(entity: RegistrarConfigEntity)

Create a response DTO from an entity.

Parameters :
Name Type Optional Description
entity RegistrarConfigEntity No
  • The registrar config entity

The response DTO with password masked

import { ApiProperty, OmitType } from "@nestjs/swagger";
import { RegistrarConfigEntity } from "../entities/registrar-config.entity";

/**
 * DTO for the registrar configuration response.
 * Excludes the password field for security and includes a flag indicating if a password is set.
 */
export class RegistrarConfigResponseDto extends OmitType(
    RegistrarConfigEntity,
    ["tenant", "tenantId", "password"] as const,
) {
    /**
     * Indicates whether a password is configured.
     * The actual password is never returned for security reasons.
     */
    @ApiProperty({
        description:
            "Indicates whether a password is configured (actual password is never returned)",
        example: true,
    })
    hasPassword!: boolean;

    /**
     * Create a response DTO from an entity.
     * @param entity - The registrar config entity
     * @returns The response DTO with password masked
     */
    static fromEntity(
        entity: RegistrarConfigEntity,
    ): RegistrarConfigResponseDto {
        const dto = new RegistrarConfigResponseDto();
        dto.registrarUrl = entity.registrarUrl;
        dto.oidcUrl = entity.oidcUrl;
        dto.clientId = entity.clientId;
        dto.clientSecret = entity.clientSecret;
        dto.username = entity.username;
        dto.hasPassword = !!entity.password;
        return dto;
    }
}

results matching ""

    No results matching ""