mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
fix: update the permission for viewing provider pages
This commit is contained in:
@@ -48,9 +48,9 @@ async function normalizeProxyPoolId(proxyPoolId) {
|
||||
}
|
||||
|
||||
// GET /api/providers - List all connections
|
||||
export async function GET() {
|
||||
export async function GET(request) {
|
||||
try {
|
||||
const { ownerId } = await getProviderConnectionAccess();
|
||||
const { ownerId } = await getProviderConnectionAccess(request);
|
||||
const connections = await getProviderConnections(ownerId ? { ownerId } : {});
|
||||
|
||||
// Build nodeNameMap for compatible providers (id → name)
|
||||
@@ -83,6 +83,9 @@ export async function GET() {
|
||||
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 fetching providers:", error);
|
||||
return NextResponse.json({ error: "Failed to fetch providers" }, { status: 500 });
|
||||
}
|
||||
@@ -91,7 +94,7 @@ export async function GET() {
|
||||
// POST /api/providers - Create new connection (API Key only, OAuth via separate flow)
|
||||
export async function POST(request) {
|
||||
try {
|
||||
const { user } = await getProviderConnectionAccess();
|
||||
const { user } = await getProviderConnectionAccess(request);
|
||||
const body = await request.json();
|
||||
const provider = normalizeProviderId(body.provider);
|
||||
const { apiKey, name, displayName, priority, globalPriority, defaultModel, testStatus } = body;
|
||||
@@ -205,6 +208,9 @@ export async function POST(request) {
|
||||
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 creating provider:", error);
|
||||
return NextResponse.json(
|
||||
{ error: error.status === 409 ? error.message : "Failed to create provider" },
|
||||
|
||||
Reference in New Issue
Block a user