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
Patch subscription plan frontend validation
Tuan Dang98efffafaa5b
diff --git a/backend/src/ee/services/EELicenseService.ts b/backend/src/ee/services/EELicenseService.tsindex 527a847304..c98a5a449f 100644--- a/backend/src/ee/services/EELicenseService.ts+++ b/backend/src/ee/services/EELicenseService.ts@@ -95,6 +95,13 @@ class EELicenseService {return this.globalFeatureSet;}++ public async refreshOrganizationPlan(organizationId: string) {+ if (this.instanceType === 'cloud') {+ this.localFeatureSet.del(organizationId);+ await this.getOrganizationPlan(organizationId);+ }+ }public async initGlobalFeatureSet() {const licenseServerKey = await getLicenseServerKey();diff --git a/backend/src/helpers/organization.ts b/backend/src/helpers/organization.tsindex 71e8c15ce1..3e7f169d04 100644--- a/backend/src/helpers/organization.ts+++ b/backend/src/helpers/organization.ts@@ -153,22 +153,24 @@ export const updateSubscriptionOrgQuantity = async ({EELicenseService.localFeatureSet.del(organizationId);}+ }++ if (EELicenseService.instanceType === 'enterprise-self-hosted') {+ // instance of Infisical is an enterprise self-hosted instance- if (EELicenseService.instanceType === 'enterprise-self-hosted') {- // instance of Infisical is an enterprise self-hosted instance-- const usedSeats = await MembershipOrg.countDocuments({- status: ACCEPTED- });+ const usedSeats = await MembershipOrg.countDocuments({+ status: ACCEPTED+ });- await licenseKeyRequest.patch(- `${await getLicenseServerUrl()}/api/license/v1/license`,- {- usedSeats- }- );- }+ await licenseKeyRequest.patch(+ `${await getLicenseServerUrl()}/api/license/v1/license`,+ {+ usedSeats+ }+ );}+ await EELicenseService.refreshOrganizationPlan(organizationId);+return stripeSubscription;};\ No newline at end of filediff --git a/backend/src/helpers/workspace.ts b/backend/src/helpers/workspace.tsindex a1d71e920d..8b15d1baf6 100644--- a/backend/src/helpers/workspace.ts+++ b/backend/src/helpers/workspace.ts@@ -6,6 +6,7 @@ import {Secret} from '../models';import { createBot } from '../helpers/bot';+import { EELicenseService } from '../ee/services';import { SecretService } from '../services';/**@@ -22,24 +23,25 @@ export const createWorkspace = async ({name: string;organizationId: string;}) => {- // create workspace- const workspace = await new Workspace({- name,- organization: organizationId,- autoCapitalization: true- }).save();+ // create workspace+ const workspace = await new Workspace({+ name,+ organization: organizationId,+ autoCapitalization: true+ }).save();- // initialize bot for workspace- await createBot({- name: 'Infisical Bot',- workspaceId: workspace._id- });+ // initialize bot for workspace+ await createBot({+ name: 'Infisical Bot',+ workspaceId: workspace._id+ });- // initialize blind index salt for workspace- await SecretService.createSecretBlindIndexData({- workspaceId: workspace._id- });+ // initialize blind index salt for workspace+ await SecretService.createSecretBlindIndexData({+ workspaceId: workspace._id+ });+ await EELicenseService.refreshOrganizationPlan(organizationId);return workspace;};diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.tsindex 5d01611bd0..61736b4f4e 100644--- a/frontend/src/hooks/api/subscriptions/types.ts+++ b/frontend/src/hooks/api/subscriptions/types.ts@@ -1,7 +1,7 @@export type SubscriptionPlan = {_id: string;membersUsed: number;- membersLimit: number;+ memberLimit: number;auditLogs: boolean;customAlerts: boolean;customRateLimits: boolean;diff --git a/frontend/src/layouts/AppLayout/AppLayout.tsx b/frontend/src/layouts/AppLayout/AppLayout.tsxindex be04e0bad5..7ce1f33d23 100644--- a/frontend/src/layouts/AppLayout/AppLayout.tsx+++ b/frontend/src/layouts/AppLayout/AppLayout.tsx@@ -61,7 +61,7 @@ export const AppLayout = ({ children }: LayoutProps) => {const { subscription } = useSubscription();const host = window.location.origin;- const isAddingProjectsAllowed = ((subscription?.workspacesUsed || 1) < (subscription?.workspaceLimit || 3)) || host !== 'https://app.infisical.com';+ const isAddingProjectsAllowed = subscription?.workspaceLimit ? (subscription.workspacesUsed < subscription.workspaceLimit) : true;const createWs = useCreateWorkspace();const uploadWsKey = useUploadWsKey();diff --git a/frontend/src/views/Settings/OrgSettingsPage/OrgSettingsPage.tsx b/frontend/src/views/Settings/OrgSettingsPage/OrgSettingsPage.tsxindex edf4e98a72..a0097b6aae 100644--- a/frontend/src/views/Settings/OrgSettingsPage/OrgSettingsPage.tsx+++ b/frontend/src/views/Settings/OrgSettingsPage/OrgSettingsPage.tsx@@ -60,7 +60,7 @@ export const OrgSettingsPage = () => {const [completeInviteLink, setcompleteInviteLink] = useState<string | undefined>('');- const isMoreUsersNotAllowed = ((subscription?.membersUsed || 0) >= (subscription?.membersLimit || 1)) && host === 'https://app.infisical.com';+ const isMoreUsersNotAllowed = subscription?.memberLimit ? (subscription.membersUsed >= subscription.memberLimit) : false;const onRenameOrg = async (name: string) => {if (!currentOrg?._id) return;