mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 22:49:27 +02:00
Also limit to org
This commit is contained in:
parent
dca2a29865
commit
afea958aca
2 changed files with 17 additions and 13 deletions
|
@ -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`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue