mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 03:28:43 +00:00
Update secret-approval-policy-service.ts
This commit is contained in:
@@ -61,14 +61,13 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
policyId
|
policyId
|
||||||
}: {
|
}: {
|
||||||
envId: string;
|
envId: string;
|
||||||
secretPath?: string | null;
|
secretPath: string;
|
||||||
policyId?: string;
|
policyId?: string;
|
||||||
}) => {
|
}) => {
|
||||||
const policy = await secretApprovalPolicyDAL
|
const policy = await secretApprovalPolicyDAL
|
||||||
.findOne({
|
.findOne({
|
||||||
envId,
|
envId,
|
||||||
// For environment-wide policies, we store the path as an empty string, even though the column is nullable; for that reason we check for an empty string.
|
secretPath,
|
||||||
...(secretPath ? { secretPath } : { secretPath: "" }),
|
|
||||||
deletedAt: null
|
deletedAt: null
|
||||||
})
|
})
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
@@ -288,7 +287,13 @@ export const secretApprovalPolicyServiceFactory = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await $policyExists({ envId: secretApprovalPolicy.envId, secretPath, policyId: secretApprovalPolicy.id })) {
|
if (
|
||||||
|
await $policyExists({
|
||||||
|
envId: secretApprovalPolicy.envId,
|
||||||
|
secretPath: secretPath || secretApprovalPolicy.secretPath,
|
||||||
|
policyId: secretApprovalPolicy.id
|
||||||
|
})
|
||||||
|
) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: `A policy for secret path '${secretPath}' already exists in environment '${secretApprovalPolicy.environment.slug}'`
|
message: `A policy for secret path '${secretPath}' already exists in environment '${secretApprovalPolicy.environment.slug}'`
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user