feat: changed all org permission signature

This commit is contained in:
=
2025-10-20 18:57:03 +05:30
parent ef6282968b
commit 9a7849c12b
58 changed files with 1797 additions and 1182 deletions
+24 -20
View File
@@ -5,6 +5,7 @@ import slugify from "@sindresorhus/slugify";
import {
AccessScope,
ActionProjectType,
OrganizationActionScope,
ProjectMembershipRole,
ProjectType,
ProjectVersion,
@@ -245,13 +246,14 @@ export const projectServiceFactory = ({
type = ProjectType.SecretManager
}: TCreateProjectDTO) => {
const organization = await orgDAL.findOne({ id: actorOrgId });
const { permission } = await permissionService.getOrgPermission(
const { permission } = await permissionService.getOrgPermission({
scope: OrganizationActionScope.Any,
actor,
actorId,
organization.id,
orgId: organization.id,
actorAuthMethod,
actorOrgId
);
});
if (
permission.cannot(OrgPermissionActions.Create, OrgPermissionSubjects.Workspace) &&
@@ -296,6 +298,7 @@ export const projectServiceFactory = ({
projectTemplate = await projectTemplateService.findProjectTemplateByName(template, {
id: actorId,
orgId: organization.id,
parentOrgId: organization.id,
type: actor,
authMethod: actorAuthMethod
});
@@ -513,13 +516,14 @@ export const projectServiceFactory = ({
: await projectDAL.findUserProjects(actorId, actorOrgId, type);
if (includeRoles) {
const { permission } = await permissionService.getOrgPermission(
const { permission } = await permissionService.getOrgPermission({
scope: OrganizationActionScope.Any,
actor,
actorId,
actorOrgId,
orgId: actorOrgId,
actorAuthMethod,
actorOrgId
);
});
// `includeRoles` is specifically used by organization admins when inviting new users to the organizations to avoid looping redundant api calls.
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Create, OrgPermissionSubjects.Member);
@@ -1822,13 +1826,13 @@ export const projectServiceFactory = ({
projectIds
}: TSearchProjectsDTO) => {
// check user belong to org
await permissionService.getOrgPermission(
permission.type,
permission.id,
permission.orgId,
permission.authMethod,
permission.orgId
);
await permissionService.getOrgPermission({
actor: permission.type,
actorId: permission.id,
orgId: permission.orgId,
actorAuthMethod: permission.authMethod,
scope: OrganizationActionScope.Any
});
return projectDAL.searchProjects({
limit,
@@ -1846,13 +1850,13 @@ export const projectServiceFactory = ({
const requestProjectAccess = async ({ permission, comment, projectId }: TProjectAccessRequestDTO) => {
// check user belong to org
await permissionService.getOrgPermission(
permission.type,
permission.id,
permission.orgId,
permission.authMethod,
permission.orgId
);
await permissionService.getOrgPermission({
actor: permission.type,
actorId: permission.id,
orgId: permission.orgId,
actorAuthMethod: permission.authMethod,
scope: OrganizationActionScope.Any
});
const projectMember = await permissionService
.getProjectPermission({