diff --git a/src/features/database/actions/database-delete.action.ts b/src/features/database/actions/database-delete.action.ts index 9c4bf6bf..5bc7f2c5 100644 --- a/src/features/database/actions/database-delete.action.ts +++ b/src/features/database/actions/database-delete.action.ts @@ -60,9 +60,7 @@ async function assertCanDeleteDatabase(databaseId: string): Promise { const canManage = activeMember ? computeOrganizationPermissions(activeMember).canManageAgents : false; - // Only the organization that CREATED the agent may delete its databases. - // A system agent merely attributed to an org via the join table is - // handled by the isAdmin branch above (agent.organizationId === null). + const hasAccess = !!organization && agent.organizationId === organization.id; authorized = canManage && hasAccess;