refactor: Cal.diy (#28903)
* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main: - Rebrand Cal.com to Cal.diy across the entire codebase - Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions - Switch license from AGPL-3.0 to MIT - Remove docs/ directory (migrated to Nextra at cal.diy) - Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc. - Clean up .env.example for self-hosted Cal.diy - Update Docker image references to calcom/cal.diy - Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork - Add PR welcome bot for Cal.diy contributors - Fix API v2 breaking changes oasdiff ignore entries - Replace Blacksmith CI runners with default GitHub Actions 3893 files changed, 20789 insertions(+), 411020 deletions(-) Co-Authored-By: [email protected] <[email protected]> * refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * rip out org related comments in api v2 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
a17f28e9ab
commit
ab21c7f805
4080 files changed
+14403
-404922
No files matched your search
@@ -1,80 +0,0 @@
|
||||
import { signIn } from "next-auth/react";
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useFormContext } from "react-hook-form";
|
||||
import z from "zod";
|
||||
|
||||
import { LastUsed, useLastUsed } from "../hooks/useLastUsed";
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
import { emailRegex } from "@calcom/lib/emailSchema";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { ButtonProps } from "@calcom/ui/components/button";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
interface Props {
|
||||
samlTenantID: string;
|
||||
samlProductID: string;
|
||||
setErrorMessage: Dispatch<SetStateAction<string | null>>;
|
||||
}
|
||||
|
||||
const schema = z.object({
|
||||
email: z.string().regex(emailRegex, { message: "Please enter a valid email" }),
|
||||
});
|
||||
|
||||
export function SAMLLogin({
|
||||
samlTenantID,
|
||||
samlProductID,
|
||||
setErrorMessage,
|
||||
...buttonProps
|
||||
}: Props & ButtonProps) {
|
||||
const { t } = useLocale();
|
||||
const methods = useFormContext();
|
||||
const [lastUsed, setLastUsed] = useLastUsed();
|
||||
|
||||
const mutation = trpc.viewer.public.samlTenantProduct.useMutation({
|
||||
onSuccess: async (data) => {
|
||||
setLastUsed("saml");
|
||||
await signIn("saml", {}, { tenant: data.tenant, product: data.product });
|
||||
},
|
||||
onError: (err) => {
|
||||
setErrorMessage(t(err.message));
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<Button
|
||||
StartIcon="lock"
|
||||
color="secondary"
|
||||
data-testid="samlAndOidc"
|
||||
className="flex w-full justify-center"
|
||||
onClick={async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
if (!HOSTED_CAL_FEATURES) {
|
||||
await signIn("saml", {}, { tenant: samlTenantID, product: samlProductID });
|
||||
return;
|
||||
}
|
||||
|
||||
// Hosted solution, fetch tenant and product from the backend
|
||||
const email = methods.getValues("email");
|
||||
const parsed = schema.safeParse({ email });
|
||||
|
||||
if (!parsed.success) {
|
||||
const {
|
||||
fieldErrors: { email },
|
||||
} = parsed.error.flatten();
|
||||
|
||||
setErrorMessage(email ? email[0] : null);
|
||||
return;
|
||||
}
|
||||
|
||||
mutation.mutate({
|
||||
email,
|
||||
});
|
||||
}}
|
||||
{...buttonProps}>
|
||||
<span>{t("signin_with_saml_oidc")}</span>
|
||||
{lastUsed === "saml" && <LastUsed />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -6,10 +6,8 @@ import { emailRegex } from "@calcom/lib/emailSchema";
|
||||
import { getSafeRedirectUrl } from "@calcom/lib/getSafeRedirectUrl";
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { SAMLLogin } from "@calcom/web/modules/auth/components/SAMLLogin";
|
||||
import { LastUsed, useLastUsed } from "@calcom/web/modules/auth/hooks/useLastUsed";
|
||||
import AddToHomescreen from "@components/AddToHomescreen";
|
||||
import BackupCode from "@components/auth/BackupCode";
|
||||
@@ -107,9 +105,6 @@ export default function Login({
|
||||
csrfToken,
|
||||
isGoogleLoginEnabled,
|
||||
isOutlookLoginEnabled,
|
||||
isSAMLLoginEnabled,
|
||||
samlTenantID,
|
||||
samlProductID,
|
||||
totpEmail,
|
||||
}: PageProps) {
|
||||
const searchParams = useCompatSearchParams();
|
||||
@@ -155,21 +150,6 @@ export default function Login({
|
||||
|
||||
callbackUrl = safeCallbackUrl || "";
|
||||
|
||||
const { data, isPending, error } = trpc.viewer.public.ssoConnections.useQuery();
|
||||
|
||||
useEffect(
|
||||
function refactorMeWithoutEffect() {
|
||||
if (error) {
|
||||
setErrorMessage(error.message);
|
||||
}
|
||||
},
|
||||
[error]
|
||||
);
|
||||
|
||||
const displaySSOLogin = HOSTED_CAL_FEATURES
|
||||
? true
|
||||
: isSAMLLoginEnabled && !isPending && data?.connectionExists;
|
||||
|
||||
const onSubmit = async (values: LoginValues) => {
|
||||
setErrorMessage(null);
|
||||
// telemetry.event(telemetryEventTypes.login, collectPageParameters());
|
||||
@@ -203,7 +183,7 @@ export default function Login({
|
||||
<div className="w-full rounded-xl border border-subtle bg-default p-10 shadow-sm">
|
||||
{/* Logo */}
|
||||
<div className="mb-2 text-center">
|
||||
<h1 className="font-cal text-xl font-bold text-emphasis">Cal.com</h1>
|
||||
<h1 className="font-cal text-xl font-bold text-emphasis">Cal.diy</h1>
|
||||
</div>
|
||||
|
||||
{/* Heading */}
|
||||
@@ -399,19 +379,6 @@ export default function Login({
|
||||
{t("create_account")}
|
||||
</Link>
|
||||
)}
|
||||
{displaySSOLogin && (
|
||||
<>
|
||||
{showSignupLink && <span className="text-subtle">·</span>}
|
||||
<SAMLLogin
|
||||
samlTenantID={samlTenantID}
|
||||
samlProductID={samlProductID}
|
||||
setErrorMessage={setErrorMessage}
|
||||
color="minimal"
|
||||
StartIcon={undefined}
|
||||
className="text-sm font-medium text-emphasis hover:underline p-0 h-auto"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { signIn } from "next-auth/react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
// To handle the IdP initiated login flow callback
|
||||
export default function SamlIdp({ code }: { code: string }) {
|
||||
useEffect(() => {
|
||||
signIn("saml-idp", {
|
||||
callbackUrl: "/",
|
||||
code,
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import AdminAppsList from "~/apps/components/AdminAppsList";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
@@ -11,38 +11,25 @@ import { WizardForm } from "@calcom/ui/components/form";
|
||||
import type { WizardStep } from "@calcom/ui/components/form/wizard/WizardForm";
|
||||
|
||||
import { AdminUserContainer as AdminUser } from "@components/setup/AdminUser";
|
||||
import LicenseSelection from "@components/setup/LicenseSelection";
|
||||
|
||||
import type { getServerSideProps } from "@server/lib/setup/getServerSideProps";
|
||||
|
||||
const SETUP_VIEW_SETPS = {
|
||||
ADMIN_USER: 1,
|
||||
LICENSE: 2,
|
||||
APPS: 3,
|
||||
APPS: 2,
|
||||
} as const;
|
||||
|
||||
export type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
export function Setup(props: PageProps) {
|
||||
const [hasPickedAGPLv3, setHasPickedAGPLv3] = useState(false);
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const [licenseOption, setLicenseOption] = useState<"FREE" | "EXISTING">(
|
||||
props.hasValidLicense ? "EXISTING" : "FREE"
|
||||
);
|
||||
|
||||
const hasLicenseStep = !props.hasValidLicense && !hasPickedAGPLv3;
|
||||
|
||||
const defaultStep = useMemo(() => {
|
||||
if (props.userCount > 0) {
|
||||
if (hasLicenseStep) {
|
||||
return SETUP_VIEW_SETPS.LICENSE;
|
||||
} else {
|
||||
// License step is not shown, so apps step is at position 2 instead of 3
|
||||
return SETUP_VIEW_SETPS.APPS - 1;
|
||||
}
|
||||
return SETUP_VIEW_SETPS.APPS;
|
||||
}
|
||||
return SETUP_VIEW_SETPS.ADMIN_USER;
|
||||
}, [props.userCount, hasLicenseStep]);
|
||||
}, [props.userCount]);
|
||||
|
||||
const steps: WizardStep[] = [
|
||||
{
|
||||
@@ -67,36 +54,6 @@ export function Setup(props: PageProps) {
|
||||
},
|
||||
];
|
||||
|
||||
// Only show license selection step if there's no valid license already and AGPLv3 wasn't picked
|
||||
if (hasLicenseStep) {
|
||||
steps.push({
|
||||
title: t("choose_a_license"),
|
||||
description: t("choose_license_description"),
|
||||
customActions: true,
|
||||
content: (setIsPending, nav) => {
|
||||
return (
|
||||
<LicenseSelection
|
||||
id="wizard-step-2"
|
||||
name="wizard-step-2"
|
||||
value={licenseOption}
|
||||
onChange={setLicenseOption}
|
||||
onSubmit={(values) => {
|
||||
setIsPending(true);
|
||||
if (licenseOption === "FREE") {
|
||||
setHasPickedAGPLv3(true);
|
||||
nav.onNext();
|
||||
} else if (licenseOption === "EXISTING" && values.licenseKey) {
|
||||
nav.onNext();
|
||||
}
|
||||
}}
|
||||
onPrevStep={nav.onPrev}
|
||||
onNextStep={nav.onNext}
|
||||
/>
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
steps.push({
|
||||
title: t("enable_apps"),
|
||||
description: t("enable_apps_description", { appName: APP_NAME }),
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { signIn } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
||||
|
||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
import type { getServerSideProps } from "@server/lib/auth/sso/direct/getServerSideProps";
|
||||
|
||||
// This page is used to initiate the SAML authentication flow by redirecting to the SAML provider.
|
||||
// Accessible only on self-hosted Cal.com instances.
|
||||
|
||||
export type SSODirectPageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
export default function Page({ samlTenantID, samlProductID }: SSODirectPageProps) {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
if (HOSTED_CAL_FEATURES) {
|
||||
router.push("/auth/login");
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
// Initiate SAML authentication flow
|
||||
signIn(
|
||||
"saml",
|
||||
{
|
||||
callbackUrl: "/",
|
||||
},
|
||||
{ tenant: samlTenantID, product: samlProductID }
|
||||
);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { signIn } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
|
||||
|
||||
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
import type { getServerSideProps } from "@server/lib/auth/sso/[provider]/getServerSideProps";
|
||||
|
||||
export type SSOProviderPageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
|
||||
export default function Provider(props: SSOProviderPageProps) {
|
||||
const searchParams = useCompatSearchParams();
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
const email = searchParams?.get("email");
|
||||
if (props.provider === "saml") {
|
||||
if (!email) {
|
||||
router.push(`/auth/error?error=Email not provided`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!props.isSAMLLoginEnabled) {
|
||||
router.push(`/auth/error?error=SAML login not enabled`);
|
||||
return;
|
||||
}
|
||||
|
||||
signIn("saml", {}, { tenant: props.tenant, product: props.product });
|
||||
} else if (props.provider === "google" && email) {
|
||||
signIn("google", {}, { login_hint: email });
|
||||
} else if (props.provider === "microsoft") {
|
||||
signIn("azure-ad");
|
||||
} else {
|
||||
signIn(props.provider);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ const EMAIL_CLIENTS = [
|
||||
{
|
||||
name: "Yahoo",
|
||||
icon: "/email-clients/yahoo.svg",
|
||||
href: "https://mail.yahoo.com/d/search?p=Cal.com",
|
||||
href: "https://mail.yahoo.com/d/search?p=Cal.diy",
|
||||
},
|
||||
{
|
||||
name: "Proton",
|
||||
|
||||
Reference in new issue
Block a user