Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(auth): show SSO options on /auth/sign-up (#564)

Marc Klingen578f55f444dc
diff --git a/src/components/layouts/layout.tsx b/src/components/layouts/layout.tsx
index fddb7e860d..a206ec63ea 100644
--- a/src/components/layouts/layout.tsx
+++ b/src/components/layouts/layout.tsx
@@ -108,7 +108,7 @@ export default function Layout(props: PropsWithChildren) {
router.pathname.startsWith("/public/");
if (hideNavigation)
return (
- <main className="h-full bg-gray-50 px-4 py-4 sm:px-6 lg:px-8">
+ <main className="min-h-screen bg-gray-50 px-4 py-4 sm:px-6 lg:px-8">
{props.children}
</main>
);
diff --git a/src/pages/auth/sign-in.tsx b/src/pages/auth/sign-in.tsx
index 445e52ab4c..f883750969 100644
--- a/src/pages/auth/sign-in.tsx
+++ b/src/pages/auth/sign-in.tsx
@@ -32,7 +32,8 @@ const credentialAuthForm = z.object({
}),
});
-type PageProps = {
+// Also used in src/pages/auth/sign-up.tsx
+export type PageProps = {
authProviders: {
credentials: boolean;
google: boolean;
@@ -40,6 +41,7 @@ type PageProps = {
};
};
+// Also used in src/pages/auth/sign-up.tsx
// eslint-disable-next-line @typescript-eslint/require-await
export const getServerSideProps: GetServerSideProps<PageProps> = async () => {
return {
@@ -57,7 +59,54 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async () => {
};
};
-export default function SignIn(props: PageProps) {
+// Also used in src/pages/auth/sign-up.tsx
+export function SSOButtons({
+ authProviders,
+ action = "Sign in",
+}: PageProps & { action?: string }) {
+ const posthog = usePostHog();
+
+ return (
+ // any authprovider from props is enanbles
+ Object.entries(authProviders).some(
+ ([name, enabled]) => enabled && name !== "credentials",
+ ) ? (
+ <div>
+ {authProviders.credentials ? (
+ <Divider className="text-gray-400" />
+ ) : null}
+ <div className="flex flex-row flex-wrap items-center justify-center gap-4">
+ {authProviders.google ? (
+ <Button
+ onClick={() => {
+ posthog.capture("sign_in:google_button_click");
+ void signIn("google");
+ }}
+ variant="secondary"
+ >
+ <FcGoogle className="mr-3" size={18} />
+ {action} with Google
+ </Button>
+ ) : null}
+ {authProviders.github ? (
+ <Button
+ onClick={() => {
+ posthog.capture("sign_in:github_button_click");
+ void signIn("github");
+ }}
+ variant="secondary"
+ >
+ <FaGithub className="mr-3" size={18} />
+ {action} with Github
+ </Button>
+ ) : null}
+ </div>
+ </div>
+ ) : null
+ );
+}
+
+export default function SignIn({ authProviders }: PageProps) {
const [credentialsFormError, setCredentialsFormError] = useState<
string | null
>(null);
@@ -102,9 +151,9 @@ export default function SignIn(props: PageProps) {
</div>
<div className="mt-14 bg-white px-6 py-10 shadow sm:mx-auto sm:w-full sm:max-w-[480px] sm:rounded-lg sm:px-12">
- <div className="mt-2 space-y-8">
+ <div className="space-y-8">
<CloudRegionSwitch />
- {props.authProviders.credentials ? (
+ {authProviders.credentials ? (
<Form {...credentialsForm}>
<form
className="space-y-6"
@@ -154,51 +203,13 @@ export default function SignIn(props: PageProps) {
</form>
</Form>
) : null}
-
- {
- // any authprovider from props is enanbles
- Object.entries(props.authProviders).some(
- ([name, enabled]) => enabled && name !== "credentials",
- ) ? (
- <div>
- {props.authProviders.credentials ? (
- <Divider className="text-gray-400" />
- ) : null}
- <div className="flex flex-row flex-wrap items-center justify-center gap-4">
- {props.authProviders.google ? (
- <Button
- onClick={() => {
- posthog.capture("sign_in:google_button_click");
- void signIn("google");
- }}
- variant="secondary"
- >
- <FcGoogle className="mr-3" size={18} />
- Sign in with Google
- </Button>
- ) : null}
- {props.authProviders.github ? (
- <Button
- onClick={() => {
- posthog.capture("sign_in:github_button_click");
- void signIn("github");
- }}
- variant="secondary"
- >
- <FaGithub className="mr-3" size={18} />
- Sign in with Github
- </Button>
- ) : null}
- </div>
- </div>
- ) : null
- }
+ <SSOButtons authProviders={authProviders} />
</div>
<CloudPrivacyNotice action="signing in" />
</div>
{env.NEXT_PUBLIC_SIGN_UP_DISABLED !== "true" &&
- props.authProviders.credentials ? (
+ authProviders.credentials ? (
<p className="mt-10 text-center text-sm text-gray-500">
No account yet?{" "}
<Link
diff --git a/src/pages/auth/sign-up.tsx b/src/pages/auth/sign-up.tsx
index 9c3df4f6fd..4d373ea4a5 100644
--- a/src/pages/auth/sign-up.tsx
+++ b/src/pages/auth/sign-up.tsx
@@ -21,8 +21,12 @@ import { LangfuseIcon } from "@/src/components/LangfuseLogo";
import { usePostHog } from "posthog-js/react";
import { CloudPrivacyNotice } from "@/src/features/auth/components/AuthCloudPrivacyNotice";
import { CloudRegionSwitch } from "@/src/features/auth/components/AuthCloudRegionSwitch";
+import { SSOButtons, type PageProps } from "@/src/pages/auth/sign-in";
-export default function SignIn() {
+// Use the same getServerSideProps function as src/pages/auth/sign-in.tsx
+export { getServerSideProps } from "@/src/pages/auth/sign-in";
+
+export default function SignIn({ authProviders }: PageProps) {
const posthog = usePostHog();
const [formError, setFormError] = useState<string | null>(null);
const form = useForm<z.infer<typeof signupSchema>>({
@@ -86,7 +90,10 @@ export default function SignIn() {
</div>
{env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION !== undefined ? (
<div className="text-center sm:mx-auto sm:w-full sm:max-w-[480px]">
- No credit card required. All users have access to a demo project.
+ No credit card required.{" "}
+ {env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION === "EU"
+ ? "All users have access to a demo project."
+ : null}
</div>
) : null}
@@ -169,6 +176,7 @@ export default function SignIn() {
) : null}
</form>
</Form>
+ <SSOButtons authProviders={authProviders} action="Sign up" />
<CloudPrivacyNotice action="creating an account" />
</div>