Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Update refreshPlan to consider workspace
Tuan Dang82a026a426eb
diff --git a/backend/src/controllers/v2/environmentController.ts b/backend/src/controllers/v2/environmentController.tsindex d4f91bacec..d3ff5d0abc 100644--- a/backend/src/controllers/v2/environmentController.ts+++ b/backend/src/controllers/v2/environmentController.ts@@ -8,6 +8,7 @@ import {Membership,} from '../../models';import { SecretVersion } from '../../ee/models';+import { EELicenseService } from '../../ee/services';import { BadRequestError } from '../../utils/errors';import _ from 'lodash';import { PERMISSION_READ_SECRETS, PERMISSION_WRITE_SECRETS } from '../../variables';@@ -40,6 +41,8 @@ export const createWorkspaceEnvironment = async (});await workspace.save();+ await EELicenseService.refreshPlan(workspace.organization.toString(), workspaceId);+return res.status(200).send({message: 'Successfully created new environment',workspace: workspaceId,@@ -186,7 +189,9 @@ export const deleteWorkspaceEnvironment = async (await Membership.updateMany({ workspace: workspaceId },{ $pull: { deniedPermissions: { environmentSlug: environmentSlug } } }- )+ );++ await EELicenseService.refreshPlan(workspace.organization.toString(), workspaceId);return res.status(200).send({message: 'Successfully deleted environment',diff --git a/backend/src/ee/services/EELicenseService.ts b/backend/src/ee/services/EELicenseService.tsindex 85a27de991..e8fe9253eb 100644--- a/backend/src/ee/services/EELicenseService.ts+++ b/backend/src/ee/services/EELicenseService.ts@@ -104,9 +104,9 @@ class EELicenseService {return this.globalFeatureSet;}- public async refreshOrganizationPlan(organizationId: string, workspaceId?: string) {+ public async refreshPlan(organizationId: string, workspaceId?: string) {if (this.instanceType === 'cloud') {- this.localFeatureSet.del(organizationId);+ this.localFeatureSet.del(`${organizationId}-${workspaceId ?? ''}`);await this.getPlan(organizationId, workspaceId);}}diff --git a/backend/src/helpers/organization.ts b/backend/src/helpers/organization.tsindex 3e7f169d04..b88fbdf126 100644--- a/backend/src/helpers/organization.ts+++ b/backend/src/helpers/organization.ts@@ -170,7 +170,7 @@ export const updateSubscriptionOrgQuantity = async ({);}- await EELicenseService.refreshOrganizationPlan(organizationId);+ await EELicenseService.refreshPlan(organizationId);return stripeSubscription;};\ No newline at end of filediff --git a/backend/src/helpers/workspace.ts b/backend/src/helpers/workspace.tsindex 8b15d1baf6..694540f862 100644--- a/backend/src/helpers/workspace.ts+++ b/backend/src/helpers/workspace.ts@@ -41,7 +41,7 @@ export const createWorkspace = async ({workspaceId: workspace._id});- await EELicenseService.refreshOrganizationPlan(organizationId);+ await EELicenseService.refreshPlan(organizationId);return workspace;};