From dc01d09f09ad7363753835bcb3ed6957998d66cc Mon Sep 17 00:00:00 2001 From: gosangam Date: Tue, 2 Jun 2026 15:21:47 +0530 Subject: [PATCH] login with facebook added --- components/auth/oauth-buttons.tsx | 46 ++++++++++++++----------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/components/auth/oauth-buttons.tsx b/components/auth/oauth-buttons.tsx index bc5122b2..d9e1675f 100644 --- a/components/auth/oauth-buttons.tsx +++ b/components/auth/oauth-buttons.tsx @@ -1,28 +1,23 @@ "use client"; /** - * OAuthButtons — "Continue with Google / Facebook" row used above both - * LoginForm and SignUpForm. Clicking a button performs a top-level - * navigation to the BFF's /oauth//start endpoint, which kicks off - * the Authorization Code flow. The BFF handles the round-trip and 302s back + * OAuthButtons — "Continue with …" row used above both LoginForm and + * SignUpForm. Clicking a button performs a top-level navigation to the + * BFF's /oauth//start endpoint, which kicks off the + * Authorization Code flow. The BFF handles the round-trip and 302s back * to ${frontend}${next} with the session cookie already set. * * Top-level navigation (not fetch) is intentional: cross-origin redirects * to Google / Facebook can't happen from XHR, and we need the BFF to set * the cookie before the browser lands back on the frontend. + * + * To re-enable a provider that's currently commented out, uncomment its + * block in the grid below. */ -import { useMemo } from "react"; - const BFF_BASE = process.env.NEXT_PUBLIC_BFF_URL || "http://localhost:8080"; -// Build-time switch — keep the buttons hidden until the Google + Facebook -// OAuth apps clear review. Flip `NEXT_PUBLIC_OAUTH_ENABLED=true` on the -// Next.js build (Vercel/Dokploy env vars) once approval lands; no code -// change required. Defaults to disabled so prod stays safe by default. -const OAUTH_ENABLED = process.env.NEXT_PUBLIC_OAUTH_ENABLED === "true"; - type Props = { /** Frontend path to land on after the round-trip. Defaults to /u/me. */ next?: string; @@ -31,34 +26,30 @@ type Props = { }; export function OAuthButtons({ next, showDivider = true }: Props) { - // Suppress the whole row (no buttons → no "or" divider either) while - // the OAuth apps are under review. - if (!OAUTH_ENABLED) return null; - const startUrl = useMemo( - () => (provider: "google" | "facebook") => { - const u = new URL(`${BFF_BASE}/api/v1/auth/oauth/${provider}/start`); - if (next) u.searchParams.set("next", next); - return u.toString(); - }, - [next], - ); + function startUrl(provider: "google" | "facebook"): string { + const u = new URL(`${BFF_BASE}/api/v1/auth/oauth/${provider}/start`); + if (next) u.searchParams.set("next", next); + return u.toString(); + } return (
-
+ {showDivider ? ( @@ -74,6 +65,9 @@ export function OAuthButtons({ next, showDivider = true }: Props) { ); } +// Kept exported-internally so the Google block above can be uncommented +// without re-importing or re-pasting the SVG. +// eslint-disable-next-line @typescript-eslint/no-unused-vars function GoogleIcon({ className }: { className?: string }) { return (