feat(auth): hide Google sign-in until OAuth is configured

Google social login has no credentials in production, so the "Continue with
Google" button (and its divider) errored on click. Gate the button + divider on
a new isGoogleConfigured() helper (requires GOOGLE_CLIENT_ID + GOOGLE_CLIENT_SECRET)
on both the login and signup pages, and guard the signInWithGoogle action as
defense in depth. The button reappears automatically once both env vars are set.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Leon Serfaty
2026-07-03 08:26:08 -04:00
co-authored by Claude Opus 4.8
parent e5e987eb4c
commit 595a5e3e04
4 changed files with 61 additions and 37 deletions
+6 -1
View File
@@ -3,7 +3,7 @@
import { redirect } from "next/navigation"
import { headers } from "next/headers"
import { APIError } from "better-auth/api"
import { auth } from "@/lib/auth"
import { auth, isGoogleConfigured } from "@/lib/auth"
import { verifyTurnstile } from "@/lib/turnstile"
const APP_URL = process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:3000"
@@ -77,6 +77,11 @@ export async function signIn(formData: FormData) {
}
export async function signInWithGoogle() {
// Defense in depth: the auth pages hide the Google button when it isn't
// configured, but guard the action too in case it's POSTed directly.
if (!isGoogleConfigured()) {
redirect(`/login?error=${encodeURIComponent("Google sign-in isn't available right now.")}`)
}
let url: string | undefined
try {
const res = await auth.api.signInSocial({