Files
calendar/apps/web/modules/auth/sso/provider-view.tsx
T
f8dc7a115a chore: App Router - remove references to /pages for remaining pages in /auth, /insights, /d, signup and add missing default /future page (#16589)
* remove references to /pages for sso, setup, signin pages in /auth

* remove references to pages for insights

* remove references to pages for d

* remove references to pages for signup

* add page for /future index page

* fix routing-forms

* fix

* add missing defaults

* use getServerSessionForAppDir instead

* fix apps/[slug]/[...pages]

* fix metadata in apps/slug/pages

* refactor

* refactor

* remove duplicate code for PageProps

* remove references to pages for /reschedule

* fix

* fix routing forms

* type fix

* fix routing forms again

* revert changes for app/slug/pages

* revert

* revert changes in yarn lock

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
2024-09-19 15:06:51 +00:00

42 lines
1.2 KiB
TypeScript

"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 {
signIn(props.provider);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
}