mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-20 03:46:38 +00:00
Allow picking ips when creating stuff
This commit is contained in:
@@ -71,7 +71,7 @@ export async function createOrg(
|
||||
|
||||
const { orgId, name, subnet } = parsedBody.data;
|
||||
|
||||
if (subnet && !isValidCIDR(subnet)) {
|
||||
if (!isValidCIDR(subnet)) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.BAD_REQUEST,
|
||||
@@ -80,6 +80,22 @@ export async function createOrg(
|
||||
);
|
||||
}
|
||||
|
||||
// make sure the subnet is unique
|
||||
const subnetExists = await db
|
||||
.select()
|
||||
.from(orgs)
|
||||
.where(eq(orgs.subnet, subnet))
|
||||
.limit(1);
|
||||
|
||||
if (subnetExists.length > 0) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.CONFLICT,
|
||||
`Subnet ${subnet} already exists`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// make sure the orgId is unique
|
||||
const orgExists = await db
|
||||
.select()
|
||||
|
||||
Reference in New Issue
Block a user