mirror of
https://github.com/papra-hq/papra.git
synced 2025-12-16 20:24:27 -06:00
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:
5
.changeset/hungry-walls-brush.md
Normal file
5
.changeset/hungry-walls-brush.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@papra/app-server": patch
|
||||
---
|
||||
|
||||
Removed the possibility for unauthorized upload to another organization you're not member of
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user