refactor: use enums

This commit is contained in:
Mohamed Marrouchi
2025-01-16 17:41:30 +01:00
parent 4fac5d4fc9
commit 359049ff3d
22 changed files with 124 additions and 90 deletions

View File

@@ -26,7 +26,7 @@ import { Action } from '@/user/types/action.type';
import { TModel } from '@/user/types/model.type';
import { AttachmentService } from '../services/attachment.service';
import { AttachmentResourceRef, TAttachmentResourceRef } from '../types';
import { AttachmentResourceRef } from '../types';
import {
isAttachmentResourceRef,
isAttachmentResourceRefArray,
@@ -42,7 +42,7 @@ export class AttachmentGuard implements CanActivate {
private permissionMap: Record<
Action,
Record<TAttachmentResourceRef, [TModel, Action][]>
Record<AttachmentResourceRef, [TModel, Action][]>
> = {
// Read attachments by ref
[Action.READ]: {
@@ -169,7 +169,7 @@ export class AttachmentGuard implements CanActivate {
private async isAuthorized(
action: Action,
user: Express.User & User,
resourceRef: TAttachmentResourceRef,
resourceRef: AttachmentResourceRef,
): Promise<boolean> {
if (!action) {
throw new TypeError('Invalid action');