feat: Enable admins to list all collections in workspace

This commit is contained in:
Tom Moor
2023-05-11 22:25:12 -04:00
parent 0ce9931910
commit 7ce97f4d50

View File

@@ -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<Collection> = {
teamId: user.teamId,
id: collectionIds,
};
const where: WhereOptions<Collection> =
includeListOnly && user.isAdmin
? {
teamId: user.teamId,
}
: {
teamId: user.teamId,
id: collectionIds,
};
const collections = await Collection.scope({
method: ["withMembership", user.id],
}).findAll({