mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 21:27:31 +00:00
Modify convention for PostHog isPaid attr to be tier-based instead of slug
This commit is contained in:
@@ -1,17 +1,15 @@
|
|||||||
import to from 'await-to-js';
|
|
||||||
import { Types } from 'mongoose';
|
import { Types } from 'mongoose';
|
||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
import { ISecret, Secret, Workspace } from '../../models';
|
import { ISecret, Secret, Workspace } from '../../models';
|
||||||
import { IAction, SecretVersion } from '../../ee/models';
|
import { IAction, SecretVersion } from '../../ee/models';
|
||||||
import {
|
import {
|
||||||
SECRET_PERSONAL,
|
SECRET_PERSONAL,
|
||||||
SECRET_SHARED,
|
|
||||||
ACTION_ADD_SECRETS,
|
ACTION_ADD_SECRETS,
|
||||||
ACTION_READ_SECRETS,
|
ACTION_READ_SECRETS,
|
||||||
ACTION_UPDATE_SECRETS,
|
ACTION_UPDATE_SECRETS,
|
||||||
ACTION_DELETE_SECRETS
|
ACTION_DELETE_SECRETS
|
||||||
} from '../../variables';
|
} from '../../variables';
|
||||||
import { UnauthorizedRequestError, ValidationError } from '../../utils/errors';
|
import { UnauthorizedRequestError, WorkspaceNotFoundError } from '../../utils/errors';
|
||||||
import { EventService } from '../../services';
|
import { EventService } from '../../services';
|
||||||
import { eventPushSecrets } from '../../events';
|
import { eventPushSecrets } from '../../events';
|
||||||
import { EESecretService, EELogService, EELicenseService } from '../../ee/services';
|
import { EESecretService, EELogService, EELicenseService } from '../../ee/services';
|
||||||
@@ -20,7 +18,7 @@ import { getChannelFromUserAgent } from '../../utils/posthog';
|
|||||||
import { PERMISSION_WRITE_SECRETS } from '../../variables';
|
import { PERMISSION_WRITE_SECRETS } from '../../variables';
|
||||||
import { userHasNoAbility, userHasWorkspaceAccess, userHasWriteOnlyAbility } from '../../ee/helpers/checkMembershipPermissions';
|
import { userHasNoAbility, userHasWorkspaceAccess, userHasWriteOnlyAbility } from '../../ee/helpers/checkMembershipPermissions';
|
||||||
import Tag from '../../models/tag';
|
import Tag from '../../models/tag';
|
||||||
import _, { eq } from 'lodash';
|
import _ from 'lodash';
|
||||||
import {
|
import {
|
||||||
BatchSecretRequest,
|
BatchSecretRequest,
|
||||||
BatchSecret
|
BatchSecret
|
||||||
@@ -49,13 +47,11 @@ export const batchSecrets = async (req: Request, res: Response) => {
|
|||||||
requests: BatchSecretRequest[];
|
requests: BatchSecretRequest[];
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
const organizationId = (
|
const workspace = await Workspace.findById(workspaceId);
|
||||||
await Workspace.findOne({
|
if (!workspace) throw WorkspaceNotFoundError();
|
||||||
_id: workspaceId
|
|
||||||
})
|
const orgPlan = await EELicenseService.getOrganizationPlan(workspace.organization.toString());
|
||||||
)?.organization?.toString();
|
const isPaid = orgPlan.tier < 1;
|
||||||
const orgPlan = await EELicenseService.getOrganizationPlan(organizationId || '');
|
|
||||||
const isPaid = orgPlan.slug != 'starter';
|
|
||||||
|
|
||||||
const createSecrets: BatchSecret[] = [];
|
const createSecrets: BatchSecret[] = [];
|
||||||
const updateSecrets: BatchSecret[] = [];
|
const updateSecrets: BatchSecret[] = [];
|
||||||
@@ -387,13 +383,11 @@ export const createSecrets = async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const organizationId = (
|
const workspace = await Workspace.findById(workspaceId);
|
||||||
await Workspace.findOne({
|
if (!workspace) throw WorkspaceNotFoundError();
|
||||||
_id: workspaceId
|
|
||||||
})
|
const orgPlan = await EELicenseService.getOrganizationPlan(workspace.organization.toString());
|
||||||
)?.organization?.toString();
|
const isPaid = orgPlan.tier < 1;
|
||||||
const orgPlan = await EELicenseService.getOrganizationPlan(organizationId || '');
|
|
||||||
const isPaid = orgPlan.slug != 'starter';
|
|
||||||
|
|
||||||
let listOfSecretsToCreate;
|
let listOfSecretsToCreate;
|
||||||
if (Array.isArray(req.body.secrets)) {
|
if (Array.isArray(req.body.secrets)) {
|
||||||
@@ -615,13 +609,11 @@ export const getSecrets = async (req: Request, res: Response) => {
|
|||||||
const normalizedPath = normalizePath(secretsPath as string)
|
const normalizedPath = normalizePath(secretsPath as string)
|
||||||
const folders = await getFoldersInDirectory(workspaceId as string, environment as string, normalizedPath)
|
const folders = await getFoldersInDirectory(workspaceId as string, environment as string, normalizedPath)
|
||||||
|
|
||||||
const organizationId = (
|
const workspace = await Workspace.findById(workspaceId);
|
||||||
await Workspace.findOne({
|
if (!workspace) throw WorkspaceNotFoundError();
|
||||||
_id: workspaceId
|
|
||||||
})
|
const orgPlan = await EELicenseService.getOrganizationPlan(workspace.organization.toString());
|
||||||
)?.organization?.toString();
|
const isPaid = orgPlan.tier < 1;
|
||||||
const orgPlan = await EELicenseService.getOrganizationPlan(organizationId || '');
|
|
||||||
const isPaid = orgPlan.slug != 'starter';
|
|
||||||
|
|
||||||
// secrets to return
|
// secrets to return
|
||||||
let secrets: ISecret[] = [];
|
let secrets: ISecret[] = [];
|
||||||
@@ -967,13 +959,11 @@ export const updateSecrets = async (req: Request, res: Response) => {
|
|||||||
workspaceId: new Types.ObjectId(key)
|
workspaceId: new Types.ObjectId(key)
|
||||||
})
|
})
|
||||||
|
|
||||||
const organizationId = (
|
const workspace = await Workspace.findById(key);
|
||||||
await Workspace.findOne({
|
if (!workspace) throw WorkspaceNotFoundError();
|
||||||
_id: key
|
|
||||||
})
|
const orgPlan = await EELicenseService.getOrganizationPlan(workspace.organization.toString());
|
||||||
)?.organization?.toString();
|
const isPaid = orgPlan.tier < 1;
|
||||||
const orgPlan = await EELicenseService.getOrganizationPlan(organizationId || '');
|
|
||||||
const isPaid = orgPlan.slug != 'starter';
|
|
||||||
|
|
||||||
const postHogClient = await TelemetryService.getPostHogClient();
|
const postHogClient = await TelemetryService.getPostHogClient();
|
||||||
if (postHogClient) {
|
if (postHogClient) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class EELicenseService {
|
|||||||
public globalFeatureSet: FeatureSet = {
|
public globalFeatureSet: FeatureSet = {
|
||||||
_id: null,
|
_id: null,
|
||||||
slug: null,
|
slug: null,
|
||||||
tier: null,
|
tier: -1,
|
||||||
projectLimit: null,
|
projectLimit: null,
|
||||||
memberLimit: null,
|
memberLimit: null,
|
||||||
secretVersioning: true,
|
secretVersioning: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user