Also limit to org

This commit is contained in:
Owen 2025-07-18 11:48:14 -07:00
parent dca2a29865
commit afea958aca
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
2 changed files with 17 additions and 13 deletions

View file

@ -144,14 +144,16 @@ export async function createClient(
const subnetExistsClients = await db
.select()
.from(clients)
.where(eq(clients.subnet, updatedSubnet))
.where(
and(eq(clients.subnet, updatedSubnet), eq(clients.orgId, orgId))
)
.limit(1);
if (subnetExistsClients.length > 0) {
return next(
createHttpError(
HttpCode.CONFLICT,
`Subnet ${subnet} already exists`
`Subnet ${updatedSubnet} already exists in clients`
)
);
}
@ -159,14 +161,16 @@ export async function createClient(
const subnetExistsSites = await db
.select()
.from(sites)
.where(eq(sites.address, updatedSubnet))
.where(
and(eq(sites.address, updatedSubnet), eq(sites.orgId, orgId))
)
.limit(1);
if (subnetExistsSites.length > 0) {
return next(
createHttpError(
HttpCode.CONFLICT,
`Subnet ${subnet} already exists`
`Subnet ${updatedSubnet} already exists in sites`
)
);
}