From 7ce97f4d50463478f25087e0aaf57808f7fa92f9 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 11 May 2023 22:25:12 -0400 Subject: [PATCH] feat: Enable admins to list all collections in workspace --- server/routes/api/collections.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/routes/api/collections.ts b/server/routes/api/collections.ts index 369737527..56baf0ecb 100644 --- a/server/routes/api/collections.ts +++ b/server/routes/api/collections.ts @@ -761,12 +761,18 @@ router.post( auth(), pagination(), async (ctx: APIContext) => { + const { includeListOnly } = ctx.request.body; const { user } = ctx.state.auth; const collectionIds = await user.collectionIds(); - const where: WhereOptions = { - teamId: user.teamId, - id: collectionIds, - }; + const where: WhereOptions = + includeListOnly && user.isAdmin + ? { + teamId: user.teamId, + } + : { + teamId: user.teamId, + id: collectionIds, + }; const collections = await Collection.scope({ method: ["withMembership", user.id], }).findAll({