julianlam/nodebb-plugin-session-sharing

Update User Groups doesnt remove groups when groups is empty array

Closed this issue · 2 comments

If a user was previously in one group and is removed via there cookie claims so the groups is an empty array the updateUserGroups function doesnt process the data to force a leave of the previous group due to the userData.groups.length check.

So even though their claims say no groups, the forum still has them in the last group they had.

I think removing the userData.groups.length and maybe replacing it with Array.isArray check should fix the issue. Thought?

if (!userData.groups || !userData.groups.length) {
return setImmediate(callback, null, uid, isNewUser);
}

@uplift Yes, that makes sense, will make the appropriate change

v4.5.0