fix: update the permission for viewing provider pages

This commit is contained in:
2026-07-15 17:56:14 +07:00
parent 4b0acbfc69
commit 5c8d9f80b0
45 changed files with 362 additions and 340 deletions
+4 -1
View File
@@ -7,7 +7,7 @@ import { getProviderConnectionAccess } from "@/lib/providers/connectionAccess";
export async function POST(request, { params }) {
try {
const { id } = await params;
const { ownerId } = await getProviderConnectionAccess();
const { ownerId } = await getProviderConnectionAccess(request);
const connection = await getProviderConnectionById(id, ownerId);
if (!connection) {
return NextResponse.json({ error: "Connection not found" }, { status: 404 });
@@ -27,6 +27,9 @@ export async function POST(request, { params }) {
if (error.message === "Unauthorized") {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
if (error.message === "Forbidden") {
return NextResponse.json({ error: "Administrator access required" }, { status: 403 });
}
console.log("Error testing connection:", error);
return NextResponse.json({ error: "Test failed" }, { status: 500 });
}