docs: Add documentation for groups API endpoints (#1211)

* docs: Add documentation for groups API endpoints
fix: Remove useless permission query param

* restore permission filter on collections.group_memberships

* tweak language
This commit is contained in:
Tom Moor
2020-03-16 08:30:15 -07:00
committed by GitHub
parent e611979a8d
commit 4851f51d8b
2 changed files with 155 additions and 26 deletions

View File

@@ -148,20 +148,14 @@ router.post('groups.delete', auth(), async ctx => {
});
router.post('groups.memberships', auth(), pagination(), async ctx => {
const { id, query, permission } = ctx.body;
const { id, query } = ctx.body;
ctx.assertUuid(id, 'id is required');
const user = ctx.state.user;
const group = await Group.findByPk(id);
authorize(user, 'read', group);
let where = {
groupId: id,
};
let userWhere;
if (query) {
userWhere = {
name: {
@@ -170,15 +164,8 @@ router.post('groups.memberships', auth(), pagination(), async ctx => {
};
}
if (permission) {
where = {
...where,
permission,
};
}
const memberships = await GroupUser.findAll({
where,
where: { groupId: id },
order: [['createdAt', 'DESC']],
offset: ctx.state.pagination.offset,
limit: ctx.state.pagination.limit,