2023-03-07 18:33:16 +00:00
|
|
|
import { signIn } from "next-auth/react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
|
|
|
import { samlProductID, samlTenantID } from "@calcom/features/ee/sso/lib/saml";
|
|
|
|
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
|
|
|
|
|
|
|
|
import type { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
import PageWrapper from "@components/PageWrapper";
|
|
|
|
|
2023-03-07 18:33:16 +00:00
|
|
|
// 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 default function Page({ samlTenantID, samlProductID }: inferSSRProps<typeof getServerSideProps>) {
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
if (HOSTED_CAL_FEATURES) {
|
|
|
|
router.push("/auth/login");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initiate SAML authentication flow
|
|
|
|
signIn(
|
|
|
|
"saml",
|
|
|
|
{
|
|
|
|
callbackUrl: "/",
|
|
|
|
},
|
|
|
|
{ tenant: samlTenantID, product: samlProductID }
|
|
|
|
);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-04-18 18:45:32 +00:00
|
|
|
Page.PageWrapper = PageWrapper;
|
|
|
|
|
2023-03-07 18:33:16 +00:00
|
|
|
export async function getServerSideProps() {
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
samlTenantID,
|
|
|
|
samlProductID,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|