mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-02-13 19:15:44 +01:00
- Fix syntax errors in skills markdown files (.github/skills, .opencode/skills) - Change typescript to tsx for code blocks with JSX - Replace ellipsis (...) in array examples with valid syntax - Separate CSS from TypeScript into distinct code blocks - Convert JavaScript object examples to valid JSON in docs - Fix enum definitions with proper comma separation
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { type NextRequest, NextResponse } from "next/server";
|
|
import { neonAuth } from "@/lib/auth/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
// MIGRATED: Removed "export const dynamic = 'force-dynamic'" - dynamic by default with Cache Components
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const { session: authSession, user: authUser } = await neonAuth();
|
|
if (!authSession || !authUser?.email) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
// Look up user in our database to get companyId and role
|
|
const user = await prisma.user.findUnique({
|
|
where: { email: authUser.email },
|
|
select: { companyId: true, role: true },
|
|
});
|
|
|
|
if (!user || !user.companyId) {
|
|
return NextResponse.json(
|
|
{ error: "User not found or no company" },
|
|
{ status: 401 }
|
|
);
|
|
}
|
|
|
|
// Check for admin role
|
|
if (user.role !== "ADMIN") {
|
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
|
}
|
|
|
|
const body = await request.json();
|
|
const { csvUrl, csvUsername, csvPassword } = body;
|
|
|
|
await prisma.company.update({
|
|
where: { id: user.companyId },
|
|
data: {
|
|
csvUrl,
|
|
csvUsername,
|
|
...(csvPassword ? { csvPassword } : {}),
|
|
// Remove sentimentAlert field - not in current schema
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({ ok: true });
|
|
}
|