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

v1.18.x
Julian Lam 5 years ago
parent e1c40b2792
commit 68ecf41ecf

@ -1,6 +1,5 @@
'use strict';
define('forum/groups/details', [
'forum/groups/memberlist',
'iconSelect',
@ -9,7 +8,8 @@ define('forum/groups/details', [
'pictureCropper',
'translator',
'vendor/colorpicker/colorpicker',
], function (memberList, iconSelect, components, coverPhoto, pictureCropper, translator) {
'api',
], function (memberList, iconSelect, components, coverPhoto, pictureCropper, translator, api) {
var Details = {};
var groupName;
@ -106,7 +106,10 @@ define('forum/groups/details', [
break;
case 'join': // intentional fall-throughs!
case 'leave':
api.put('/groups/' + ajaxify.data.group.slug + '/membership/' + (uid || app.user.uid), undefined, () => ajaxify.refresh(), err => app.alertError(err.status.message));
break;
case 'leave': // intentional fall-throughs!
case 'accept':
case 'reject':
case 'issueInvite':

@ -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)) {

Loading…
Cancel
Save