We need to generate a niceId every time we make a client

This commit is contained in:
Owen
2025-12-07 11:07:08 -05:00
parent 110e950476
commit 5e9d660e26

View File

@@ -22,6 +22,7 @@ import { isIpInCidr } from "@server/lib/ip";
import { listExitNodes } from "#dynamic/lib/exitNodes"; import { listExitNodes } from "#dynamic/lib/exitNodes";
import { OpenAPITags, registry } from "@server/openApi"; import { OpenAPITags, registry } from "@server/openApi";
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations"; import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
import { getUniqueClientName } from "@server/db/names";
const paramsSchema = z const paramsSchema = z
.object({ .object({
@@ -211,11 +212,14 @@ export async function createUserClient(
); );
} }
const niceId = await getUniqueClientName(orgId);
[newClient] = await trx [newClient] = await trx
.insert(clients) .insert(clients)
.values({ .values({
exitNodeId: randomExitNode.exitNodeId, exitNodeId: randomExitNode.exitNodeId,
orgId, orgId,
niceId,
name, name,
subnet: updatedSubnet, subnet: updatedSubnet,
type, type,