Skip to content

Commit

Permalink
BC-7879 - fix AuthorizationContextParams to handle enum types corre…
Browse files Browse the repository at this point in the history
…ctly
  • Loading branch information
bergatco committed Oct 15, 2024
1 parent 6752c05 commit 757b5e8
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import { Permission } from '@shared/domain/interface';
import { ApiProperty } from '@nestjs/swagger';
import { Permission } from '@shared/domain/interface';
import { Type } from 'class-transformer';
import { IsArray, IsEnum, IsMongoId, ValidateNested } from 'class-validator';
import { Action, AuthorizableReferenceType, AuthorizationContext } from '../../domain';

class AuthorizationContextParams implements AuthorizationContext {
@IsEnum(Action)
@ApiProperty({
description: 'Define for which action the operation should be performend.',
name: 'action',
enum: Action,
enumName: 'Action',
description: 'Define for which action the operation should be performend.',
example: Action.read,
})
action!: Action;

@IsArray()
@IsEnum(Permission, { each: true })
@ApiProperty({
name: 'requiredPermissions',
enum: Permission,
enumName: 'Permission',
isArray: true,
description: 'User permissions that are needed to execute the operation.',
example: Permission.USER_UPDATE,
example: [Permission.USER_UPDATE],
})
requiredPermissions!: Permission[];
}
Expand Down

0 comments on commit 757b5e8

Please sign in to comment.