From f622752233af745cfa225098ccbd06d3c03f9610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C4=B0pek?= Date: Fri, 10 Apr 2026 22:50:02 +0300 Subject: [PATCH] feat(auth): enhance registration page with OAuth support for Google and GitHub --- app/(auth)/register/page.tsx | 15 +++- app/(auth)/register/register-page-client.tsx | 78 +++++++++++++++++++- 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/app/(auth)/register/page.tsx b/app/(auth)/register/page.tsx index af5e9d6..0351415 100644 --- a/app/(auth)/register/page.tsx +++ b/app/(auth)/register/page.tsx @@ -2,5 +2,18 @@ import { isInviteCodeRequired } from '@/lib/feature-flags'; import RegisterPageClient from './register-page-client'; export default function RegisterPage() { - return ; + const googleEnabled = Boolean( + process.env.GOOGLE_CLIENT_ID && process.env.GOOGLE_CLIENT_SECRET, + ); + const githubEnabled = Boolean( + process.env.GITHUB_CLIENT_ID && process.env.GITHUB_CLIENT_SECRET, + ); + + return ( + + ); } diff --git a/app/(auth)/register/register-page-client.tsx b/app/(auth)/register/register-page-client.tsx index 30f7c7c..738e57c 100644 --- a/app/(auth)/register/register-page-client.tsx +++ b/app/(auth)/register/register-page-client.tsx @@ -4,12 +4,19 @@ import { useEffect, useMemo, useState } from 'react'; import Link from 'next/link'; import { useRouter, useSearchParams } from 'next/navigation'; import { Video, Loader2, KeyRound, UserPlus } from 'lucide-react'; +import { signIn } from 'next-auth/react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; -export default function RegisterPageClient({ requireInviteCode }: { requireInviteCode: boolean }) { +interface RegisterPageClientProps { + requireInviteCode: boolean; + googleEnabled: boolean; + githubEnabled: boolean; +} + +export default function RegisterPageClient({ requireInviteCode, googleEnabled, githubEnabled }: RegisterPageClientProps) { const router = useRouter(); const searchParams = useSearchParams(); const invitationToken = useMemo(() => searchParams.get('invitationToken') || '', [searchParams]); @@ -17,6 +24,7 @@ export default function RegisterPageClient({ requireInviteCode }: { requireInvit const isInvitationFlow = invitationToken.length > 0; const shouldShowInviteCode = requireInviteCode && !isInvitationFlow; const [isLoading, setIsLoading] = useState(false); + const [oauthLoading, setOauthLoading] = useState(null); const [error, setError] = useState(''); const [formData, setFormData] = useState({ name: '', @@ -87,6 +95,15 @@ export default function RegisterPageClient({ requireInviteCode }: { requireInvit } }; + const handleOAuthSignUp = async (provider: string) => { + setOauthLoading(provider); + setError(''); + await signIn(provider, { callbackUrl: '/dashboard' }); + }; + + const hasOAuth = googleEnabled || githubEnabled; + const anyLoading = isLoading || oauthLoading !== null; + return (
@@ -106,6 +123,63 @@ export default function RegisterPageClient({ requireInviteCode }: { requireInvit + {/* OAuth Buttons */} + {hasOAuth && ( +
+ {googleEnabled && ( + + )} + {githubEnabled && ( + + )} +
+ )} + + {/* Divider */} + {hasOAuth && ( +
+
+ +
+
+ or continue with email +
+
+ )} +
{isInvitationFlow ? (
@@ -202,7 +276,7 @@ export default function RegisterPageClient({ requireInviteCode }: { requireInvit
)} -