feat: add the tiktok integration

This commit is contained in:
Pierre Ryssen
2026-03-10 15:14:14 +01:00
parent 0dca836cf5
commit cd15c81b53
18 changed files with 701 additions and 39 deletions

View File

@@ -0,0 +1,30 @@
import { NextResponse } from "next/server";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
export async function POST() {
const session = await auth();
if (!session?.user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const userId = (session.user as { id?: string }).id;
if (!userId) {
return NextResponse.json({ error: "Session error" }, { status: 401 });
}
try {
// Supprimer le token TikTok
await prisma.tikTokToken.deleteMany({ where: { userId } });
// Supprimer le TrackedAccount associé
await prisma.trackedAccount.deleteMany({ where: { userId, platform: "tiktok" } });
return NextResponse.json({ success: true });
} catch (err) {
console.error("[TikTok disconnect error]", err);
return NextResponse.json({ error: "Disconnect failed" }, { status: 500 });
}
}