import { Trans } from '@lingui/react/macro'; import { Link, redirect } from 'react-router'; import { extractCookieFromHeaders } from '@documenso/auth/server/lib/utils/cookies'; import { getOptionalSession } from '@documenso/auth/server/lib/utils/get-session'; import { IS_GOOGLE_SSO_ENABLED, IS_OIDC_SSO_ENABLED, OIDC_PROVIDER_LABEL, } from '@documenso/lib/constants/auth'; import { env } from '@documenso/lib/utils/env'; import { SignInForm } from '~/components/forms/signin'; import { appMetaTags } from '~/utils/meta'; import type { Route } from './+types/signin'; export function meta() { return appMetaTags('Sign In'); } export async function loader({ request }: Route.LoaderArgs) { const { isAuthenticated } = await getOptionalSession(request); const redirectToCookie = extractCookieFromHeaders('redirectTo', request.headers); const redirectToAfterLogin = redirectToCookie ? decodeURIComponent(redirectToCookie) : ''; const isGoogleSSOEnabled = IS_GOOGLE_SSO_ENABLED; const isOIDCSSOEnabled = IS_OIDC_SSO_ENABLED; const oidcProviderLabel = OIDC_PROVIDER_LABEL; if (isAuthenticated) { if (redirectToAfterLogin) { throw redirect(redirectToAfterLogin); } throw redirect('/'); } return { isGoogleSSOEnabled, isOIDCSSOEnabled, oidcProviderLabel, redirectToAfterLogin, }; } export default function SignIn({ loaderData }: Route.ComponentProps) { const { isGoogleSSOEnabled, isOIDCSSOEnabled, oidcProviderLabel, redirectToAfterLogin } = loaderData; return (