Skip to content

Scheduling infrastructure for absolutely everyone.

fix the issue "ReferenceError: window is not defined" (#8193)

Kiran K2fdadb98ac80
diff --git a/apps/web/pages/auth/sso/direct.tsx b/apps/web/pages/auth/sso/direct.tsx
index 6877def519b..d1390a3043e 100644
--- a/apps/web/pages/auth/sso/direct.tsx
+++ b/apps/web/pages/auth/sso/direct.tsx
@@ -1,5 +1,6 @@
import { signIn } from "next-auth/react";
import { useRouter } from "next/router";
+import { useEffect } from "react";
import { samlProductID, samlTenantID } from "@calcom/features/ee/sso/lib/saml";
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
@@ -13,19 +14,22 @@ import PageWrapper from "@components/PageWrapper";
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 }
- );
+ useEffect(() => {
+ if (HOSTED_CAL_FEATURES) {
+ router.push("/auth/login");
+ }
+ }, []);
+
+ useEffect(() => {
+ // Initiate SAML authentication flow
+ signIn(
+ "saml",
+ {
+ callbackUrl: "/",
+ },
+ { tenant: samlTenantID, product: samlProductID }
+ );
+ }, []);
return null;
}