mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 20:27:12 +00:00
Chore: Moved verifyApprovers
This commit is contained in:
@@ -54,7 +54,6 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
|
|
||||||
if (approvals > approvers.length)
|
if (approvals > approvers.length)
|
||||||
throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
|
throw new BadRequestError({ message: "Approvals cannot be greater than approvers" });
|
||||||
if (!secretPath) throw new BadRequestError({ message: "Secret path is required" });
|
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(
|
const { permission } = await permissionService.getProjectPermission(
|
||||||
actor,
|
actor,
|
||||||
@@ -75,6 +74,10 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
$in: { id: approvers }
|
$in: { id: approvers }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (secretApprovers.length !== approvers.length) {
|
||||||
|
throw new BadRequestError({ message: "Approver not found in project" });
|
||||||
|
}
|
||||||
|
|
||||||
await verifyApprovers({
|
await verifyApprovers({
|
||||||
projectId: project.id,
|
projectId: project.id,
|
||||||
orgId: actorOrgId,
|
orgId: actorOrgId,
|
||||||
@@ -82,13 +85,9 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
secretPath,
|
secretPath,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
permissionService,
|
permissionService,
|
||||||
approverProjectMemberships: secretApprovers
|
userIds: secretApprovers.map((approver) => approver.userId)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (secretApprovers.length !== approvers.length) {
|
|
||||||
throw new BadRequestError({ message: "Approver not found in project" });
|
|
||||||
}
|
|
||||||
|
|
||||||
const accessApproval = await accessApprovalPolicyDAL.transaction(async (tx) => {
|
const accessApproval = await accessApprovalPolicyDAL.transaction(async (tx) => {
|
||||||
const doc = await accessApprovalPolicyDAL.create(
|
const doc = await accessApprovalPolicyDAL.create(
|
||||||
{
|
{
|
||||||
@@ -111,7 +110,7 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
return { ...accessApproval, environment: env, projectId: project.id };
|
return { ...accessApproval, environment: env, projectId: project.id };
|
||||||
};
|
};
|
||||||
|
|
||||||
const getAccessApprovalPolicyByProjectId = async ({
|
const getAccessApprovalPolicyByProjectSlug = async ({
|
||||||
actorId,
|
actorId,
|
||||||
actor,
|
actor,
|
||||||
actorOrgId,
|
actorOrgId,
|
||||||
@@ -185,7 +184,7 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
secretPath: doc.secretPath!,
|
secretPath: doc.secretPath!,
|
||||||
actorAuthMethod,
|
actorAuthMethod,
|
||||||
permissionService,
|
permissionService,
|
||||||
approverProjectMemberships: secretApprovers
|
userIds: secretApprovers.map((approver) => approver.userId)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (secretApprovers.length !== approvers.length)
|
if (secretApprovers.length !== approvers.length)
|
||||||
@@ -261,7 +260,7 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
const policies = await accessApprovalPolicyDAL.find({ envId: environment.id, projectId: project.id });
|
const policies = await accessApprovalPolicyDAL.find({ envId: environment.id, projectId: project.id });
|
||||||
if (!policies) throw new BadRequestError({ message: "No policies found" });
|
if (!policies) throw new BadRequestError({ message: "No policies found" });
|
||||||
|
|
||||||
return { policyCount: policies.length };
|
return { count: policies.length };
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -269,6 +268,6 @@ export const accessApprovalPolicyServiceFactory = ({
|
|||||||
createAccessApprovalPolicy,
|
createAccessApprovalPolicy,
|
||||||
deleteAccessApprovalPolicy,
|
deleteAccessApprovalPolicy,
|
||||||
updateAccessApprovalPolicy,
|
updateAccessApprovalPolicy,
|
||||||
getAccessApprovalPolicyByProjectId
|
getAccessApprovalPolicyByProjectSlug
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user