fix: prevent SSR mismatch in OAuth URL generation (#7288)

This commit is contained in:
Pablo Lara
2025-03-18 17:22:29 +01:00
committed by Pepe Fagoaga
parent cc6db6b680
commit df11afbcf0
2 changed files with 15 additions and 4 deletions
+9 -1
View File
@@ -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 (
<AuthForm
type="sign-in"
googleAuthUrl={GOOGLE_AUTH_URL}
githubAuthUrl={GITHUB_AUTH_URL}
isGoogleOAuthEnabled={isGoogleOAuthEnabled}
isGithubOAuthEnabled={isGithubOAuthEnabled}
/>
+6 -3
View File
@@ -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