From df11afbcf08c194548f878ca67eb53c9a9fe05d0 Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Tue, 18 Mar 2025 17:22:29 +0100 Subject: [PATCH] fix: prevent SSR mismatch in OAuth URL generation (#7288) --- ui/app/(auth)/sign-in/page.tsx | 10 +++++++++- ui/components/auth/oss/auth-form.tsx | 9 ++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/app/(auth)/sign-in/page.tsx b/ui/app/(auth)/sign-in/page.tsx index cb8b2df43b..c36226e61f 100644 --- a/ui/app/(auth)/sign-in/page.tsx +++ b/ui/app/(auth)/sign-in/page.tsx @@ -1,10 +1,18 @@ import { AuthForm } from "@/components/auth/oss"; -import { isGithubOAuthEnabled, isGoogleOAuthEnabled } from "@/lib/helper"; +import { + getAuthUrl, + isGithubOAuthEnabled, + isGoogleOAuthEnabled, +} from "@/lib/helper"; const SignIn = () => { + const GOOGLE_AUTH_URL = getAuthUrl("google"); + const GITHUB_AUTH_URL = getAuthUrl("github"); return ( diff --git a/ui/components/auth/oss/auth-form.tsx b/ui/components/auth/oss/auth-form.tsx index 2ab7cefbd2..05e0852ffb 100644 --- a/ui/components/auth/oss/auth-form.tsx +++ b/ui/components/auth/oss/auth-form.tsx @@ -18,19 +18,22 @@ import { FormField, FormMessage, } from "@/components/ui/form"; -import { getAuthUrl } from "@/lib/helper"; import { ApiError, authFormSchema } from "@/types"; export const AuthForm = ({ type, invitationToken, isCloudEnv, + googleAuthUrl, + githubAuthUrl, isGoogleOAuthEnabled, isGithubOAuthEnabled, }: { type: string; invitationToken?: string | null; isCloudEnv?: boolean; + googleAuthUrl?: string; + githubAuthUrl?: string; isGoogleOAuthEnabled?: boolean; isGithubOAuthEnabled?: boolean; }) => { @@ -326,7 +329,7 @@ export const AuthForm = ({ variant="bordered" className="w-full" as="a" - href={getAuthUrl("google")} + href={googleAuthUrl} isDisabled={!isGoogleOAuthEnabled} > Continue with Google @@ -364,7 +367,7 @@ export const AuthForm = ({ variant="bordered" className="w-full" as="a" - href={getAuthUrl("github")} + href={githubAuthUrl} isDisabled={!isGithubOAuthEnabled} > Continue with Github