fix
This commit is contained in:
@@ -117,11 +117,13 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
// Read role and agent type from cookies (set by signup page before OAuth redirect)
|
||||
let role: string | undefined;
|
||||
let agentTypeId: string | undefined;
|
||||
let mode: string | undefined;
|
||||
try {
|
||||
const { cookies } = await import("next/headers");
|
||||
const cookieStore = await cookies();
|
||||
role = cookieStore.get("socialAuthRole")?.value;
|
||||
agentTypeId = cookieStore.get("socialAuthAgentTypeId")?.value;
|
||||
mode = cookieStore.get("socialAuthMode")?.value;
|
||||
} catch {
|
||||
// Cookie may not be available
|
||||
}
|
||||
@@ -139,6 +141,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
avatar: user.image,
|
||||
role,
|
||||
agentTypeId,
|
||||
mode: mode || 'signup',
|
||||
}),
|
||||
}
|
||||
);
|
||||
@@ -150,6 +153,9 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
(user as any).role = data.data.user.role;
|
||||
(user as any).accessToken = data.data.accessToken;
|
||||
(user as any).refreshToken = data.data.refreshToken;
|
||||
} else if (!res.ok) {
|
||||
const errorMsg = data?.message || "Social login failed";
|
||||
return `/login?error=${encodeURIComponent(errorMsg)}`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Social auth sync error:", error);
|
||||
|
||||
Reference in New Issue
Block a user