mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: some bugs
This commit is contained in:
@@ -42,6 +42,7 @@ export const DELETE = withApiKey(
|
||||
if (access === "forbidden") return NextResponse.json({error: "Forbidden"}, {status: 403});
|
||||
if (access === "not_found") return NextResponse.json({error: "Not found"}, {status: 404});
|
||||
|
||||
|
||||
const agent = await getAgent(id, {
|
||||
includeDatabases: false,
|
||||
includeOrganizations: true,
|
||||
@@ -51,6 +52,16 @@ export const DELETE = withApiKey(
|
||||
|
||||
const organizationIds = agent.organizations.map(org => org.organizationId)
|
||||
|
||||
const canDeleteGlobalAgent =
|
||||
ctx.user.permissions.isAdmin || ctx.user.permissions.isSuperAdmin;
|
||||
|
||||
if (!agent.organizationId && !canDeleteGlobalAgent) {
|
||||
return NextResponse.json(
|
||||
{ error: "Forbidden" },
|
||||
{ status: 403 }
|
||||
);
|
||||
}
|
||||
|
||||
await deleteAgentService({
|
||||
agentId: agent.id,
|
||||
organizationId: agent.organizationId ?? undefined,
|
||||
|
||||
@@ -69,6 +69,16 @@ export const POST = withApiKey(
|
||||
);
|
||||
}
|
||||
|
||||
const canCreateGlobalAgent =
|
||||
ctx.user.permissions.isAdmin || ctx.user.permissions.isSuperAdmin;
|
||||
|
||||
if (!organizationId && !canCreateGlobalAgent) {
|
||||
return NextResponse.json(
|
||||
{ error: "Forbidden" },
|
||||
{ status: 403 }
|
||||
);
|
||||
}
|
||||
|
||||
const createdAgent = await createAgentService({
|
||||
organizationId,
|
||||
data: {
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from "drizzle-orm/pg-core";
|
||||
import { createSelectSchema } from "drizzle-zod";
|
||||
import { z } from "zod";
|
||||
import { project } from "./06_project";
|
||||
import { member } from "@/db/schema/04_member";
|
||||
import { invitation } from "@/db/schema/05_invitation";
|
||||
import { organization } from "@/db/schema/03_organization";
|
||||
@@ -144,12 +143,6 @@ export const ssoProviderRelations = relations(ssoProvider, ({ one }) => ({
|
||||
}),
|
||||
}));
|
||||
|
||||
export const projectRelations = relations(project, ({ one }) => ({
|
||||
organization: one(organization, {
|
||||
fields: [project.organizationId],
|
||||
references: [organization.id],
|
||||
}),
|
||||
}));
|
||||
|
||||
export const passkeyRelations = relations(passkey, ({ one }) => ({
|
||||
user: one(user, {
|
||||
|
||||
@@ -66,7 +66,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "get",
|
||||
path: "/databases",
|
||||
tags,
|
||||
summary:"List databases",
|
||||
summary: "List databases",
|
||||
security,
|
||||
responses: {
|
||||
200: {
|
||||
@@ -92,7 +92,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "get",
|
||||
path: "/databases/{id}",
|
||||
tags,
|
||||
summary:"Get database by ID",
|
||||
summary: "Get database by ID",
|
||||
security,
|
||||
request: { params: z.object({ id: UuidParam }) },
|
||||
responses: {
|
||||
@@ -127,7 +127,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "get",
|
||||
path: "/databases/{id}/status",
|
||||
tags,
|
||||
summary:"Get database status",
|
||||
summary: "Get database status",
|
||||
security,
|
||||
request: { params: z.object({ id: UuidParam }) },
|
||||
responses: {
|
||||
@@ -169,7 +169,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "get",
|
||||
path: "/databases/{id}/backup",
|
||||
tags,
|
||||
summary:"List backups for a database",
|
||||
summary: "List backups for a database",
|
||||
security,
|
||||
request: { params: z.object({ id: UuidParam }) },
|
||||
responses: {
|
||||
@@ -204,7 +204,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "post",
|
||||
path: "/databases/{id}/backup",
|
||||
tags,
|
||||
summary:"Trigger a backup for a database",
|
||||
summary: "Trigger a backup for a database",
|
||||
security,
|
||||
request: { params: z.object({ id: UuidParam }) },
|
||||
responses: {
|
||||
@@ -241,7 +241,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "get",
|
||||
path: "/databases/{id}/backup/{backupId}",
|
||||
tags,
|
||||
summary:"Get a specific backup with storage details",
|
||||
summary: "Get a specific backup with storage details",
|
||||
security,
|
||||
request: {
|
||||
params: z.object({ id: UuidParam, backupId: UuidParam }),
|
||||
@@ -278,7 +278,7 @@ export function registerDatabaseRoutes(registry: OpenAPIRegistry) {
|
||||
method: "post",
|
||||
path: "/databases/{id}/restore",
|
||||
tags,
|
||||
summary:"Restore a database from a backup",
|
||||
summary: "Restore a database from a backup",
|
||||
security,
|
||||
request: {
|
||||
params: z.object({ id: UuidParam }),
|
||||
|
||||
Reference in New Issue
Block a user