fix(documents): user must be in org to upload (#660)

* fix(documents): user must be in org to upload

* chore(versioning): added changeset

Removed the possibility for unauthorized upload to another organization you're not a member of

---------

Co-authored-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
Bartek Kwiecien
2025-11-29 22:52:49 +01:00
committed by GitHub
parent 334fcbdee4
commit 9b43bafe33
2 changed files with 9 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@papra/app-server": patch
---
Removed the possibility for unauthorized upload to another organization you're not member of

View File

@@ -34,7 +34,7 @@ export function registerDocumentsRoutes(context: RouteDefinitionContext) {
}
function setupCreateDocumentRoute({ app, ...deps }: RouteDefinitionContext) {
const { config } = deps;
const { config, db } = deps;
app.post(
'/api/organizations/:organizationId/documents',
@@ -46,6 +46,9 @@ function setupCreateDocumentRoute({ app, ...deps }: RouteDefinitionContext) {
const { userId } = getUser({ context });
const { organizationId } = context.req.valid('param');
const organizationsRepository = createOrganizationsRepository({ db });
await ensureUserIsInOrganization({ userId, organizationId, organizationsRepository });
const { maxUploadSize } = config.documentsStorage;
const { fileStream, fileName, mimeType } = await getFileStreamFromMultipartForm({