mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
Improve self-hosted refresh logic
This commit is contained in:
@@ -99,6 +99,17 @@ export const licenseServiceFactory = ({
|
|||||||
const workspacesUsed = await projectDAL.countOfOrgProjects(null);
|
const workspacesUsed = await projectDAL.countOfOrgProjects(null);
|
||||||
currentPlan.workspacesUsed = workspacesUsed;
|
currentPlan.workspacesUsed = workspacesUsed;
|
||||||
|
|
||||||
|
const usedIdentitySeats = await licenseDAL.countOrgUsersAndIdentities(null);
|
||||||
|
if (usedIdentitySeats !== currentPlan.identitiesUsed) {
|
||||||
|
const usedSeats = await licenseDAL.countOfOrgMembers(null);
|
||||||
|
await licenseServerOnPremApi.request.patch(`/api/license/v1/license`, {
|
||||||
|
usedSeats,
|
||||||
|
usedIdentitySeats
|
||||||
|
});
|
||||||
|
currentPlan.identitiesUsed = usedIdentitySeats;
|
||||||
|
currentPlan.membersUsed = usedSeats;
|
||||||
|
}
|
||||||
|
|
||||||
onPremFeatures = currentPlan;
|
onPremFeatures = currentPlan;
|
||||||
logger.info("Successfully synchronized license key features");
|
logger.info("Successfully synchronized license key features");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -226,10 +237,13 @@ export const licenseServiceFactory = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const refreshPlan = async (orgId: string) => {
|
const refreshPlan = async (orgId: string) => {
|
||||||
|
await keyStore.deleteItem(FEATURE_CACHE_KEY(orgId));
|
||||||
if (instanceType === InstanceType.Cloud) {
|
if (instanceType === InstanceType.Cloud) {
|
||||||
await keyStore.deleteItem(FEATURE_CACHE_KEY(orgId));
|
|
||||||
await getPlan(orgId);
|
await getPlan(orgId);
|
||||||
}
|
}
|
||||||
|
if (instanceType === InstanceType.EnterpriseOnPrem) {
|
||||||
|
await syncLicenseKeyOnPremFeatures(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateOrgCustomerId = async (orgName: string, email?: string | null) => {
|
const generateOrgCustomerId = async (orgName: string, email?: string | null) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user