Skip to content

The Open Source DocuSign Alternative.

fix: add conditional rendering of OAuth providers (#736)

Anurag Sharma6aed075c56ee
diff --git a/apps/web/src/app/(unauthenticated)/signin/page.tsx b/apps/web/src/app/(unauthenticated)/signin/page.tsx
index 0b0333b65..5fda07e70 100644
--- a/apps/web/src/app/(unauthenticated)/signin/page.tsx
+++ b/apps/web/src/app/(unauthenticated)/signin/page.tsx
@@ -1,5 +1,7 @@
import Link from 'next/link';
+import { IS_GOOGLE_SSO_ENABLED } from '@documenso/lib/constants/auth';
+
import { SignInForm } from '~/components/forms/signin';
export default function SignInPage() {
@@ -11,7 +13,7 @@ export default function SignInPage() {
Welcome back, we are lucky to have you.
</p>
- <SignInForm className="mt-4" />
+ <SignInForm className="mt-4" isGoogleSSOEnabled={IS_GOOGLE_SSO_ENABLED} />
{process.env.NEXT_PUBLIC_DISABLE_SIGNUP !== 'true' && (
<p className="text-muted-foreground mt-6 text-center text-sm">
diff --git a/apps/web/src/components/forms/signin.tsx b/apps/web/src/components/forms/signin.tsx
index 4e671a569..038f9fe68 100644
--- a/apps/web/src/components/forms/signin.tsx
+++ b/apps/web/src/components/forms/signin.tsx
@@ -48,9 +48,10 @@ export type TSignInFormSchema = z.infer<typeof ZSignInFormSchema>;
export type SignInFormProps = {
className?: string;
+ isGoogleSSOEnabled?: boolean;
};
-export const SignInForm = ({ className }: SignInFormProps) => {
+export const SignInForm = ({ className, isGoogleSSOEnabled }: SignInFormProps) => {
const { toast } = useToast();
const [isTwoFactorAuthenticationDialogOpen, setIsTwoFactorAuthenticationDialogOpen] =
useState(false);
@@ -203,24 +204,29 @@ export const SignInForm = ({ className }: SignInFormProps) => {
{isSubmitting ? 'Signing in...' : 'Sign In'}
</Button>
- <div className="relative flex items-center justify-center gap-x-4 py-2 text-xs uppercase">
- <div className="bg-border h-px flex-1" />
- <span className="text-muted-foreground bg-transparent">Or continue with</span>
- <div className="bg-border h-px flex-1" />
- </div>
+ {isGoogleSSOEnabled && (
+ <>
+ <div className="relative flex items-center justify-center gap-x-4 py-2 text-xs uppercase">
+ <div className="bg-border h-px flex-1" />
+ <span className="text-muted-foreground bg-transparent">Or continue with</span>
+ <div className="bg-border h-px flex-1" />
+ </div>
- <Button
- type="button"
- size="lg"
- variant={'outline'}
- className="bg-background text-muted-foreground border"
- disabled={isSubmitting}
- onClick={onSignInWithGoogleClick}
- >
- <FcGoogle className="mr-2 h-5 w-5" />
- Google
- </Button>
+ <Button
+ type="button"
+ size="lg"
+ variant="outline"
+ className="bg-background text-muted-foreground border"
+ disabled={isSubmitting}
+ onClick={onSignInWithGoogleClick}
+ >
+ <FcGoogle className="mr-2 h-5 w-5" />
+ Google
+ </Button>
+ </>
+ )}
</form>
+
<Dialog
open={isTwoFactorAuthenticationDialogOpen}
onOpenChange={onCloseTwoFactorAuthenticationDialog}
diff --git a/packages/lib/constants/auth.ts b/packages/lib/constants/auth.ts
index a79293b38..9a9652b95 100644
--- a/packages/lib/constants/auth.ts
+++ b/packages/lib/constants/auth.ts
@@ -1 +1,5 @@
export const SALT_ROUNDS = 12;
+
+export const IS_GOOGLE_SSO_ENABLED = Boolean(
+ process.env.NEXT_PRIVATE_GOOGLE_CLIENT_ID && process.env.NEXT_PRIVATE_GOOGLE_CLIENT_SECRET,
+);