From 2fdadb98ac804cb861fb81b44127ae6304678a38 Mon Sep 17 00:00:00 2001 From: Kiran K Date: Wed, 19 Apr 2023 19:32:55 +0530 Subject: [PATCH] fix the issue "ReferenceError: window is not defined" (#8193) Co-authored-by: Nafees Nazik <84864519+G3root@users.noreply.github.com> Co-authored-by: nafees nazik --- apps/web/pages/auth/sso/direct.tsx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/apps/web/pages/auth/sso/direct.tsx b/apps/web/pages/auth/sso/direct.tsx index 6877def519..d1390a3043 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) { const router = useRouter(); - if (HOSTED_CAL_FEATURES) { - router.push("/auth/login"); - return; - } + useEffect(() => { + if (HOSTED_CAL_FEATURES) { + router.push("/auth/login"); + } + }, []); - // Initiate SAML authentication flow - signIn( - "saml", - { - callbackUrl: "/", - }, - { tenant: samlTenantID, product: samlProductID } - ); + useEffect(() => { + // Initiate SAML authentication flow + signIn( + "saml", + { + callbackUrl: "/", + }, + { tenant: samlTenantID, product: samlProductID } + ); + }, []); return null; }