mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 06:29:23 +02:00
Fix #1085
This commit is contained in:
parent
97b8e84143
commit
dca2a29865
2 changed files with 19 additions and 9 deletions
BIN
config/db/db.sqlite.bak
Normal file
BIN
config/db/db.sqlite.bak
Normal file
Binary file not shown.
|
@ -148,7 +148,7 @@ export async function createSite(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isIpInCidr(address, org.subnet)) {
|
if (!isIpInCidr(address, org.subnet)) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
|
@ -157,35 +157,45 @@ export async function createSite(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedAddress = `${address}/${org.subnet.split("/")[1]}`; // we want the block size of the whole org
|
updatedAddress = `${address}/${org.subnet.split("/")[1]}`; // we want the block size of the whole org
|
||||||
|
|
||||||
// make sure the subnet is unique
|
// make sure the subnet is unique
|
||||||
const addressExistsSites = await db
|
const addressExistsSites = await db
|
||||||
.select()
|
.select()
|
||||||
.from(sites)
|
.from(sites)
|
||||||
.where(eq(sites.address, updatedAddress))
|
.where(
|
||||||
|
and(
|
||||||
|
eq(sites.address, updatedAddress),
|
||||||
|
eq(sites.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (addressExistsSites.length > 0) {
|
if (addressExistsSites.length > 0) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.CONFLICT,
|
HttpCode.CONFLICT,
|
||||||
`Subnet ${subnet} already exists`
|
`Subnet ${updatedAddress} already exists in sites`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const addressExistsClients = await db
|
const addressExistsClients = await db
|
||||||
.select()
|
.select()
|
||||||
.from(clients)
|
.from(clients)
|
||||||
.where(eq(clients.subnet, updatedAddress))
|
.where(
|
||||||
|
and(
|
||||||
|
eq(clients.subnet, updatedAddress),
|
||||||
|
eq(clients.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
if (addressExistsClients.length > 0) {
|
if (addressExistsClients.length > 0) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.CONFLICT,
|
HttpCode.CONFLICT,
|
||||||
`Subnet ${subnet} already exists`
|
`Subnet ${updatedAddress} already exists in clients`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue