feat: Pass user role and agent type via cookies for social sign-up and include them in the social authentication API request.

This commit is contained in:
pradeepkumar
2026-03-26 15:18:12 +05:30
parent 2fccc0a5e3
commit d863fdb1c9
2 changed files with 24 additions and 8 deletions

View File

@@ -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 */}
<div className="flex justify-center items-center gap-8">
{/* Apple */}
<button
type="button"
className="w-10 h-10 flex items-center justify-center hover:opacity-70 transition-opacity"
>
<img src="/assets/icons/apple.svg" alt="Apple" className="w-6 h-6" />
</button>
{/* Google */}
<button
type="button"