fix(writeapi): client-side group join API call

This commit is contained in:
Julian Lam
2020-04-30 14:48:11 -04:00
parent e1c40b2792
commit 68ecf41ecf
2 changed files with 10 additions and 10 deletions

View File

@@ -54,19 +54,16 @@ Groups.join = async (req, res) => {
});
const [isCallerOwner, userExists] = await Promise.all([
groups.ownership.isOwner(req.user.uid, group.name),
user.exists(req.user.uid),
user.exists(req.params.uid),
]);
if (group.isMember) {
if (!userExists) {
throw new Error('[[error:invalid-uid]]');
} else if (group.isMember) {
// No change
return helpers.formatApiResponse(200, res);
} else if (!userExists) {
throw new Error('[[error:invalid-uid]]');
}
// console.log(res.locals.privileges);
// return res.sendStatus(200);
if (!res.locals.privileges.isAdmin) {
// Admin and privilege groups unjoinable client-side
if (group.name === 'administrators' || groups.isPrivilegeGroup(group.name)) {