Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

hide google/workos login if envs not provided

Brendan Allance6ebd61e709
diff --git a/apps/web/app/(org)/login/form.tsx b/apps/web/app/(org)/login/form.tsx
index d3ee8fb35..4f4588f19 100644
--- a/apps/web/app/(org)/login/form.tsx
+++ b/apps/web/app/(org)/login/form.tsx
@@ -19,6 +19,7 @@ import { Suspense, useEffect, useState } from "react";
import { toast } from "sonner";
import { getOrganizationSSOData } from "@/actions/organization/get-organization-sso-data";
import { trackEvent } from "@/app/utils/analytics";
+import { usePublicEnv } from "@/utils/public-env";
const MotionInput = motion(Input);
const MotionLogoBadge = motion(LogoBadge);
@@ -404,6 +405,8 @@ const NormalLogin = ({
oauthError: boolean;
handleGoogleSignIn: () => void;
}) => {
+ const publicEnv = usePublicEnv();
+
return (
<motion.div>
<motion.div layout className="flex flex-col space-y-3">
@@ -452,52 +455,59 @@ const NormalLogin = ({
Sign up here
</Link>
</motion.p>
- <div className="flex gap-4 items-center mt-4 mb-4">
- <span className="flex-1 h-px bg-gray-5" />
- <p className="text-sm text-center text-gray-10">OR</p>
- <span className="flex-1 h-px bg-gray-5" />
- </div>
- <motion.div
- layout
- className="flex flex-col gap-3 justify-center items-center"
- >
- {!oauthError && (
- <MotionButton
- variant="gray"
- type="button"
- className="flex gap-2 justify-center items-center w-full text-sm"
- onClick={handleGoogleSignIn}
- disabled={loading || emailSent}
- >
- <Image src="/google.svg" alt="Google" width={16} height={16} />
- Login with Google
- </MotionButton>
- )}
- {oauthError && (
- <div className="flex gap-3 items-center p-3 bg-red-400 rounded-xl border border-red-600">
- <FontAwesomeIcon
- className="text-gray-50 size-8"
- icon={faExclamationCircle}
- />
- <p className="text-xs leading-5 text-gray-50">
- It looks like you've previously used this email to sign up via
- email login. Please enter your email.
- </p>
+ {(publicEnv.googleAuthAvailable || publicEnv.workosAuthAvailable) && (
+ <>
+ <div className="flex gap-4 items-center mt-4 mb-4">
+ <span className="flex-1 h-px bg-gray-5" />
+ <p className="text-sm text-center text-gray-10">OR</p>
+ <span className="flex-1 h-px bg-gray-5" />
</div>
- )}
- <MotionButton
- variant="gray"
- type="button"
- className="w-full"
- layout
- onClick={() => setShowOrgInput(true)}
- disabled={loading || emailSent}
- >
- <LucideArrowUpRight size={20} />
- Login with SAML SSO
- </MotionButton>
- </motion.div>
+ <motion.div
+ layout
+ className="flex flex-col gap-3 justify-center items-center"
+ >
+ {publicEnv.googleAuthAvailable && !oauthError && (
+ <MotionButton
+ variant="gray"
+ type="button"
+ className="flex gap-2 justify-center items-center w-full text-sm"
+ onClick={handleGoogleSignIn}
+ disabled={loading || emailSent}
+ >
+ <Image src="/google.svg" alt="Google" width={16} height={16} />
+ Login with Google
+ </MotionButton>
+ )}
+
+ {oauthError && (
+ <div className="flex gap-3 items-center p-3 bg-red-400 rounded-xl border border-red-600">
+ <FontAwesomeIcon
+ className="text-gray-50 size-8"
+ icon={faExclamationCircle}
+ />
+ <p className="text-xs leading-5 text-gray-50">
+ It looks like you've previously used this email to sign up via
+ email login. Please enter your email.
+ </p>
+ </div>
+ )}
+ {publicEnv.workosAuthAvailable && (
+ <MotionButton
+ variant="gray"
+ type="button"
+ className="w-full"
+ layout
+ onClick={() => setShowOrgInput(true)}
+ disabled={loading || emailSent}
+ >
+ <LucideArrowUpRight size={20} />
+ Login with SAML SSO
+ </MotionButton>
+ )}
+ </motion.div>
+ </>
+ )}
</motion.div>
);
};
diff --git a/apps/web/app/(org)/signup/form.tsx b/apps/web/app/(org)/signup/form.tsx
index d6e1f035c..10e9dede1 100644
--- a/apps/web/app/(org)/signup/form.tsx
+++ b/apps/web/app/(org)/signup/form.tsx
@@ -19,6 +19,7 @@ import { Suspense, useEffect, useState } from "react";
import { toast } from "sonner";
import { getOrganizationSSOData } from "@/actions/organization/get-organization-sso-data";
import { trackEvent } from "@/app/utils/analytics";
+import { usePublicEnv } from "@/utils/public-env";
const MotionInput = motion(Input);
const MotionLogoBadge = motion(LogoBadge);
@@ -418,6 +419,8 @@ const NormalSignup = ({
oauthError: boolean;
handleGoogleSignIn: () => void;
}) => {
+ const publicEnv = usePublicEnv();
+
return (
<motion.div>
<motion.div layout className="flex flex-col space-y-3">
@@ -444,54 +447,64 @@ const NormalSignup = ({
Sign up with email
</MotionButton>
</motion.div>
- <div className="flex gap-4 items-center my-4">
- <span className="flex-1 h-px bg-gray-5" />
- <p className="text-sm text-center text-gray-10">OR</p>
- <span className="flex-1 h-px bg-gray-5" />
- </div>
- <motion.div
- layout
- className="flex flex-col gap-3 justify-center items-center"
- >
- {!oauthError && (
- <>
+ {(publicEnv.googleAuthAvailable || publicEnv.workosAuthAvailable) && (
+ <>
+ <div className="flex gap-4 items-center my-4">
+ <span className="flex-1 h-px bg-gray-5" />
+ <p className="text-sm text-center text-gray-10">OR</p>
+ <span className="flex-1 h-px bg-gray-5" />
+ </div>
+ <motion.div
+ layout
+ className="flex flex-col gap-3 justify-center items-center"
+ >
+ {!oauthError && (
+ <>
+ <MotionButton
+ variant="gray"
+ type="button"
+ className="flex gap-2 justify-center items-center w-full text-sm"
+ onClick={handleGoogleSignIn}
+ disabled={loading}
+ >
+ <Image
+ src="/google.svg"
+ alt="Google"
+ width={16}
+ height={16}
+ />
+ Sign up with Google
+ </MotionButton>
+ </>
+ )}
+
+ {oauthError && (
+ <div className="flex gap-3 items-center p-3 bg-red-400 rounded-xl border border-red-600">
+ <FontAwesomeIcon
+ className="text-gray-50 size-8"
+ icon={faExclamationCircle}
+ />
+ <p className="text-xs leading-5 text-gray-50">
+ It looks like you've previously used this email to sign up via
+ email. Please enter your email below to receive a sign up
+ link.
+ </p>
+ </div>
+ )}
<MotionButton
variant="gray"
type="button"
- className="flex gap-2 justify-center items-center w-full text-sm"
- onClick={handleGoogleSignIn}
+ className="w-full"
+ layout
+ onClick={() => setShowOrgInput(true)}
disabled={loading}
>
- <Image src="/google.svg" alt="Google" width={16} height={16} />
- Sign up with Google
+ <LucideArrowUpRight size={20} />
+ Sign up with SAML SSO
</MotionButton>
- </>
- )}
-
- {oauthError && (
- <div className="flex gap-3 items-center p-3 bg-red-400 rounded-xl border border-red-600">
- <FontAwesomeIcon
- className="text-gray-50 size-8"
- icon={faExclamationCircle}
- />
- <p className="text-xs leading-5 text-gray-50">
- It looks like you've previously used this email to sign up via
- email. Please enter your email below to receive a sign up link.
- </p>
- </div>
- )}
- <MotionButton
- variant="gray"
- type="button"
- className="w-full"
- layout
- onClick={() => setShowOrgInput(true)}
- disabled={loading}
- >
- <LucideArrowUpRight size={20} />
- Sign up with SAML SSO
- </MotionButton>
- </motion.div>
+ </motion.div>
+ </>
+ )}
</motion.div>
);
};
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 070f87c73..7130597f6 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -129,6 +129,8 @@ export default ({ children }: PropsWithChildren) =>
<PublicEnvContext
value={{
webUrl: buildEnv.NEXT_PUBLIC_WEB_URL,
+ workosAuthAvailable: !!serverEnv().WORKOS_CLIENT_ID,
+ googleAuthAvailable: !!serverEnv().GOOGLE_CLIENT_ID,
}}
>
<ReactQueryProvider>
diff --git a/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx b/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
index 45efd2371..a0a8ed33f 100644
--- a/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
+++ b/apps/web/app/s/[videoId]/_components/AuthOverlay.tsx
@@ -11,6 +11,7 @@ import { useId, useState } from "react";
import { toast } from "sonner";
import { trackEvent } from "@/app/utils/analytics";
import OtpForm from "./OtpForm";
+import { usePublicEnv } from "@/utils/public-env";
interface AuthOverlayProps {
isOpen: boolean;
@@ -64,7 +65,6 @@ export const AuthOverlay: React.FC<AuthOverlayProps> = ({
</div>
<div className="flex flex-col">
- <AnimatePresence> </AnimatePresence>
{step === 1 ? (
<StepOne
email={email}
@@ -145,6 +145,8 @@ const StepOne = ({
callbackUrl: `${window.location.origin}/s/${videoId}`,
});
};
+ const publicEnv = usePublicEnv();
+
return (
<form
onSubmit={async (e) => {
@@ -204,21 +206,25 @@ const StepOne = ({
: "Email sent to your inbox"
: "Continue with Email"}
</Button>
- <div className="flex gap-4 items-center">
- <span className="flex-1 h-px bg-gray-5" />
- <p className="text-sm text-center text-gray-10">OR</p>
- <span className="flex-1 h-px bg-gray-5" />
- </div>
- <Button
- variant="gray"
- type="button"
- className="flex gap-2 justify-center items-center my-1 w-full text-sm"
- onClick={handleGoogleSignIn}
- disabled={loading}
- >
- <Image src="/google.svg" alt="Google" width={16} height={16} />
- Login with Google
- </Button>
+ {publicEnv.googleAuthAvailable && (
+ <>
+ <div className="flex gap-4 items-center">
+ <span className="flex-1 h-px bg-gray-5" />
+ <p className="text-sm text-center text-gray-10">OR</p>
+ <span className="flex-1 h-px bg-gray-5" />
+ </div>
+ <Button
+ variant="gray"
+ type="button"
+ className="flex gap-2 justify-center items-center my-1 w-full text-sm"
+ onClick={handleGoogleSignIn}
+ disabled={loading}
+ >
+ <Image src="/google.svg" alt="Google" width={16} height={16} />
+ Login with Google
+ </Button>
+ </>
+ )}
</form>
);
};
diff --git a/apps/web/utils/public-env.tsx b/apps/web/utils/public-env.tsx
index 05244652e..949999239 100644
--- a/apps/web/utils/public-env.tsx
+++ b/apps/web/utils/public-env.tsx
@@ -4,6 +4,8 @@ import { createContext, type PropsWithChildren, useContext } from "react";
type PublicEnvContext = {
webUrl: string;
+ googleAuthAvailable: boolean;
+ workosAuthAvailable: boolean;
};
const Context = createContext<PublicEnvContext | null>(null);