fix: Minio urls + domain checks

This commit is contained in:
Andras Bacsai
2022-05-19 13:45:17 +02:00
parent b01f5f47b3
commit 6fb6a514ac
13 changed files with 270 additions and 96 deletions

View File

@@ -10,12 +10,14 @@ export const post: RequestHandler = async (event) => {
if (status === 401) return { status, body };
const { id } = event.params;
let { fqdn, exposePort } = await event.request.json();
let { fqdn, exposePort, otherFqdns } = await event.request.json();
if (fqdn) fqdn = fqdn.toLowerCase();
if (otherFqdns) otherFqdns = otherFqdns.map((fqdn) => fqdn.toLowerCase());
if (exposePort) exposePort = Number(exposePort);
try {
const found = await db.isDomainConfigured({ id, fqdn });
let found = await db.isDomainConfigured({ id, fqdn });
if (found) {
throw {
message: t.get('application.domain_already_in_use', {
@@ -23,6 +25,20 @@ export const post: RequestHandler = async (event) => {
})
};
}
if (otherFqdns) {
for (const ofqdn of otherFqdns) {
const domain = getDomain(ofqdn);
const nakedDomain = domain.replace('www.', '');
found = await db.isDomainConfigured({ id, fqdn: ofqdn, checkOwn: true });
if (found) {
throw {
message: t.get('application.domain_already_in_use', {
domain: nakedDomain
})
};
}
}
}
if (exposePort) {
exposePort = Number(exposePort);