mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-12 21:56:36 +00:00
Also limit to org
This commit is contained in:
@@ -144,14 +144,16 @@ export async function createClient(
|
|||||||
const subnetExistsClients = await db
|
const subnetExistsClients = await db
|
||||||
.select()
|
.select()
|
||||||
.from(clients)
|
.from(clients)
|
||||||
.where(eq(clients.subnet, updatedSubnet))
|
.where(
|
||||||
|
and(eq(clients.subnet, updatedSubnet), eq(clients.orgId, orgId))
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (subnetExistsClients.length > 0) {
|
if (subnetExistsClients.length > 0) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.CONFLICT,
|
HttpCode.CONFLICT,
|
||||||
`Subnet ${subnet} already exists`
|
`Subnet ${updatedSubnet} already exists in clients`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -159,14 +161,16 @@ export async function createClient(
|
|||||||
const subnetExistsSites = await db
|
const subnetExistsSites = await db
|
||||||
.select()
|
.select()
|
||||||
.from(sites)
|
.from(sites)
|
||||||
.where(eq(sites.address, updatedSubnet))
|
.where(
|
||||||
|
and(eq(sites.address, updatedSubnet), eq(sites.orgId, orgId))
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (subnetExistsSites.length > 0) {
|
if (subnetExistsSites.length > 0) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.CONFLICT,
|
HttpCode.CONFLICT,
|
||||||
`Subnet ${subnet} already exists`
|
`Subnet ${updatedSubnet} already exists in sites`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ export async function createSite(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let updatedAddress = null;
|
||||||
|
if (address) {
|
||||||
if (!org.subnet) {
|
if (!org.subnet) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
@@ -138,8 +140,6 @@ export async function createSite(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let updatedAddress = null;
|
|
||||||
if (address) {
|
|
||||||
if (!isValidIP(address)) {
|
if (!isValidIP(address)) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
|
|||||||
Reference in New Issue
Block a user