feat(auth): hide Google button when OAuth env is missing
- Export enabledSocialProviders from @ketopath/auth: ['google'] when GOOGLE_CLIENT_ID/SECRET are both set, [] otherwise - sign-in and sign-up pages read enabledSocialProviders server-side and pass googleEnabled to their forms; the divider and button disappear when false - No changes to the Better Auth instance — the Google provider is still conditionally registered, this just keeps the UI honest about it docs/runbooks/google-oauth-setup.md walks through the Google Cloud Console flow end-to-end (project, consent screen, credentials, redirect URIs, env injection, verification, troubleshooting, prod considerations). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c27e807c43
commit
646b98cccf
7 files changed
+180
-48
No files matched your search
@@ -1,2 +1,2 @@
|
||||
export { auth, type Auth } from './server.js';
|
||||
export { auth, enabledSocialProviders, type Auth, type SocialProvider } from './server.js';
|
||||
export { readAuthEnv, type AuthEnv } from './env.js';
|
||||
@@ -6,15 +6,20 @@ import { readAuthEnv } from './env.js';
|
||||
|
||||
const env = readAuthEnv();
|
||||
|
||||
const googleProvider =
|
||||
env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET
|
||||
? {
|
||||
google: {
|
||||
clientId: env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: env.GOOGLE_CLIENT_SECRET,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const isGoogleConfigured = Boolean(env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET);
|
||||
|
||||
export const enabledSocialProviders = isGoogleConfigured ? (['google'] as const) : ([] as const);
|
||||
|
||||
export type SocialProvider = (typeof enabledSocialProviders)[number];
|
||||
|
||||
const googleProvider = isGoogleConfigured
|
||||
? {
|
||||
google: {
|
||||
clientId: env.GOOGLE_CLIENT_ID!,
|
||||
clientSecret: env.GOOGLE_CLIENT_SECRET!,
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: prismaAdapter(prisma, { provider: 'postgresql' }),
|
||||
|
||||
Reference in new issue
Block a user