feat: Enable admins to list all collections in workspace
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user