mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-16 18:06:39 +00:00
fix update resource without subdomain
This commit is contained in:
@@ -175,10 +175,10 @@ export async function updateResource(
|
||||
);
|
||||
}
|
||||
|
||||
let fullDomain = "";
|
||||
let fullDomain: string | undefined;
|
||||
if (updateData.isBaseDomain) {
|
||||
fullDomain = org.domain;
|
||||
} else {
|
||||
} else if (updateData.subdomain) {
|
||||
fullDomain = `${updateData.subdomain}.${org.domain}`;
|
||||
}
|
||||
|
||||
@@ -187,18 +187,24 @@ export async function updateResource(
|
||||
...(fullDomain && { fullDomain })
|
||||
};
|
||||
|
||||
const [existingDomain] = await db
|
||||
.select()
|
||||
.from(resources)
|
||||
.where(eq(resources.fullDomain, fullDomain));
|
||||
if (
|
||||
fullDomain &&
|
||||
(updatePayload.subdomain !== undefined ||
|
||||
updatePayload.isBaseDomain !== undefined)
|
||||
) {
|
||||
const [existingDomain] = await db
|
||||
.select()
|
||||
.from(resources)
|
||||
.where(eq(resources.fullDomain, fullDomain));
|
||||
|
||||
if (existingDomain && existingDomain.resourceId !== resourceId) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.CONFLICT,
|
||||
"Resource with that domain already exists"
|
||||
)
|
||||
);
|
||||
if (existingDomain && existingDomain.resourceId !== resourceId) {
|
||||
return next(
|
||||
createHttpError(
|
||||
HttpCode.CONFLICT,
|
||||
"Resource with that domain already exists"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const updatedResource = await db
|
||||
|
||||
Reference in New Issue
Block a user