From d863fdb1c9909f764ae24b06ac108bd9426c65f0 Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Thu, 26 Mar 2026 15:18:12 +0530 Subject: [PATCH] feat: Pass user role and agent type via cookies for social sign-up and include them in the social authentication API request. --- src/app/(auth)/signup/page.tsx | 18 ++++++++++-------- src/auth.ts | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/app/(auth)/signup/page.tsx b/src/app/(auth)/signup/page.tsx index 7685d0a..14a6fc5 100644 --- a/src/app/(auth)/signup/page.tsx +++ b/src/app/(auth)/signup/page.tsx @@ -94,6 +94,16 @@ export default function SignUpPage() { }; const handleSocialLogin = (provider: 'google' | 'facebook' | 'twitter') => { + // If agent, require agent type selection + if (userType === 'AGENT' && !selectedAgentTypeId) { + setError('Please select an agent type before signing up'); + return; + } + // Set cookies with selected role and agent type so server-side auth callback can read them + document.cookie = `socialAuthRole=${userType};path=/;max-age=300;SameSite=Lax`; + if (userType === 'AGENT' && selectedAgentTypeId) { + document.cookie = `socialAuthAgentTypeId=${selectedAgentTypeId};path=/;max-age=300;SameSite=Lax`; + } signIn(provider, { callbackUrl: '/' }); }; @@ -317,14 +327,6 @@ export default function SignUpPage() { {/* Social Login Icons */}
- {/* Apple */} - - {/* Google */}