mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 19:28:09 +00:00
Update refreshPlan to consider workspace
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
|||||||
Membership,
|
Membership,
|
||||||
} from '../../models';
|
} from '../../models';
|
||||||
import { SecretVersion } from '../../ee/models';
|
import { SecretVersion } from '../../ee/models';
|
||||||
|
import { EELicenseService } from '../../ee/services';
|
||||||
import { BadRequestError } from '../../utils/errors';
|
import { BadRequestError } from '../../utils/errors';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { PERMISSION_READ_SECRETS, PERMISSION_WRITE_SECRETS } from '../../variables';
|
import { PERMISSION_READ_SECRETS, PERMISSION_WRITE_SECRETS } from '../../variables';
|
||||||
@@ -40,6 +41,8 @@ export const createWorkspaceEnvironment = async (
|
|||||||
});
|
});
|
||||||
await workspace.save();
|
await workspace.save();
|
||||||
|
|
||||||
|
await EELicenseService.refreshPlan(workspace.organization.toString(), workspaceId);
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
message: 'Successfully created new environment',
|
message: 'Successfully created new environment',
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
@@ -186,7 +189,9 @@ export const deleteWorkspaceEnvironment = async (
|
|||||||
await Membership.updateMany(
|
await Membership.updateMany(
|
||||||
{ workspace: workspaceId },
|
{ workspace: workspaceId },
|
||||||
{ $pull: { deniedPermissions: { environmentSlug: environmentSlug } } }
|
{ $pull: { deniedPermissions: { environmentSlug: environmentSlug } } }
|
||||||
)
|
);
|
||||||
|
|
||||||
|
await EELicenseService.refreshPlan(workspace.organization.toString(), workspaceId);
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
message: 'Successfully deleted environment',
|
message: 'Successfully deleted environment',
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ class EELicenseService {
|
|||||||
return this.globalFeatureSet;
|
return this.globalFeatureSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async refreshOrganizationPlan(organizationId: string, workspaceId?: string) {
|
public async refreshPlan(organizationId: string, workspaceId?: string) {
|
||||||
if (this.instanceType === 'cloud') {
|
if (this.instanceType === 'cloud') {
|
||||||
this.localFeatureSet.del(organizationId);
|
this.localFeatureSet.del(`${organizationId}-${workspaceId ?? ''}`);
|
||||||
await this.getPlan(organizationId, workspaceId);
|
await this.getPlan(organizationId, workspaceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ export const updateSubscriptionOrgQuantity = async ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await EELicenseService.refreshOrganizationPlan(organizationId);
|
await EELicenseService.refreshPlan(organizationId);
|
||||||
|
|
||||||
return stripeSubscription;
|
return stripeSubscription;
|
||||||
};
|
};
|
||||||
@@ -41,7 +41,7 @@ export const createWorkspace = async ({
|
|||||||
workspaceId: workspace._id
|
workspaceId: workspace._id
|
||||||
});
|
});
|
||||||
|
|
||||||
await EELicenseService.refreshOrganizationPlan(organizationId);
|
await EELicenseService.refreshPlan(organizationId);
|
||||||
|
|
||||||
return workspace;
|
return workspace;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user