diff --git a/app/api/linkedin/callback/route.ts b/app/api/linkedin/callback/route.ts index 48a08ea..d4211be 100644 --- a/app/api/linkedin/callback/route.ts +++ b/app/api/linkedin/callback/route.ts @@ -17,7 +17,6 @@ export async function POST(request: NextRequest) { }; if (!account_id || !userId) { - console.error("Unipile callback missing account_id or name:", body); return NextResponse.json( { error: "Missing account_id or user identifier" }, { status: 400 } @@ -29,18 +28,22 @@ export async function POST(request: NextRequest) { process.env.SUPABASE_SERVICE_ROLE_KEY! ); - const { error } = await supabase + const { data, error } = await supabase .from("profiles") .update({ unipile_account_id: account_id, unipile_account_status: status ?? "CONNECTED", }) - .eq("id", userId); + .eq("id", userId) + .select(); if (error) { - console.error("Error saving Unipile account_id:", error); return NextResponse.json({ error: "DB update failed" }, { status: 500 }); } + if (!data || data.length === 0) { + return NextResponse.json({ error: "Profile not found" }, { status: 404 }); + } + return NextResponse.json({ ok: true }); }