From 9913b2fb6cc429395d1ecaca8ebb5e11ccfdf605 Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Wed, 26 Jul 2023 22:20:51 +0700 Subject: [PATCH] Initialize TrustedIP upon creating a new workspace --- backend/src/helpers/workspace.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/src/helpers/workspace.ts b/backend/src/helpers/workspace.ts index d79d6c453..0f4e5dc6b 100644 --- a/backend/src/helpers/workspace.ts +++ b/backend/src/helpers/workspace.ts @@ -5,6 +5,10 @@ import { Secret, Workspace, } from "../models"; +import { + IPType, + TrustedIP +} from "../ee/models"; import { createBot } from "../helpers/bot"; import { EELicenseService } from "../ee/services"; import { SecretService } from "../services"; @@ -40,6 +44,16 @@ export const createWorkspace = async ({ await SecretService.createSecretBlindIndexData({ workspaceId: workspace._id, }); + + // initialize default trusted ip of 0.0.0.0/0 + await new TrustedIP({ + workspace: workspace._id, + ipAddress: "0.0.0.0", + type: IPType.IPV4, + prefix: 0, + isActive: true, + comment: "" + }).save() await EELicenseService.refreshPlan(organizationId);