chore: Subdomain blacklist when creating org (#9728)
Co-authored-by: Bailey Pumfleet <[email protected]> Co-authored-by: Omar López <[email protected]>
This commit is contained in:
6 files changed
+37
-29
No files matched your search
@@ -1,15 +1,4 @@
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
// Define which hostnames are expected for the app
|
||||
export const appHostnames = [
|
||||
"cal.com",
|
||||
"cal.dev",
|
||||
"cal-staging.com",
|
||||
"cal.community",
|
||||
"cal.local:3000",
|
||||
// ⬇️ Prevents 404 error for normal localhost development, makes it backwards compatible
|
||||
"localhost:3000",
|
||||
];
|
||||
import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/constants";
|
||||
|
||||
/**
|
||||
* return the org slug
|
||||
@@ -17,7 +6,7 @@ export const appHostnames = [
|
||||
*/
|
||||
export function getOrgDomain(hostname: string) {
|
||||
// Find which hostname is being currently used
|
||||
const currentHostname = appHostnames.find((ahn) => {
|
||||
const currentHostname = ALLOWED_HOSTNAMES.find((ahn) => {
|
||||
const url = new URL(WEBAPP_URL);
|
||||
const testHostname = `${url.hostname}${url.port ? `:${url.port}` : ""}`;
|
||||
return testHostname.endsWith(`.${ahn}`);
|
||||
@@ -34,8 +23,7 @@ export function orgDomainConfig(hostname: string) {
|
||||
const currentOrgDomain = getOrgDomain(hostname);
|
||||
return {
|
||||
currentOrgDomain,
|
||||
isValidOrgDomain:
|
||||
currentOrgDomain !== null && currentOrgDomain !== "app" && !appHostnames.includes(currentOrgDomain),
|
||||
isValidOrgDomain: currentOrgDomain !== null && !RESERVED_SUBDOMAINS.includes(currentOrgDomain),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user