feat: updated to enum ActionProjectType

This commit is contained in:
=
2025-01-14 23:26:18 +05:30
parent d721a46ec9
commit 6f38d6c76f
46 changed files with 347 additions and 350 deletions
@@ -2,7 +2,7 @@ import { ForbiddenError, MongoAbility, RawRuleOf, subject } from "@casl/ability"
import { PackRule, packRules, unpackRules } from "@casl/ability/extra";
import ms from "ms";
import { ProjectOperationType } from "@app/db/schemas";
import { ActionProjectType } from "@app/db/schemas";
import { isAtLeastAsPrivileged } from "@app/lib/casl";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { UnpackedPermissionSchema } from "@app/server/routes/santizedSchemas/permission";
@@ -69,7 +69,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Edit,
@@ -82,7 +82,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
// we need to validate that the privilege given is not higher than the assigning users permission
@@ -152,7 +152,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
ForbiddenError.from(permission).throwUnlessCan(
@@ -166,7 +166,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
// we need to validate that the privilege given is not higher than the assigning users permission
@@ -253,7 +253,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Edit,
@@ -266,7 +266,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
const hasRequiredPriviledges = isAtLeastAsPrivileged(permission, identityRolePermission);
if (!hasRequiredPriviledges)
@@ -312,7 +312,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionActions.Read,
@@ -355,7 +355,7 @@ export const identityProjectAdditionalPrivilegeServiceFactory = ({
projectId: identityProjectMembership.projectId,
actorAuthMethod,
actorOrgId,
projectOperationType: ProjectOperationType.Global
projectOperationType: ActionProjectType.Any
});
ForbiddenError.from(permission).throwUnlessCan(