Node.js based forum software built for the modern web
closes #5875
Barış Soner Uşaklı48165b90110c
diff --git a/src/groups/membership.js b/src/groups/membership.jsindex 8ffd845443..48bb82f56f 100644--- a/src/groups/membership.js+++ b/src/groups/membership.js@@ -251,6 +251,9 @@ module.exports = function (Groups) {next();}},+ function (next) {+ clearGroupTitleIfSet(groupName, uid, next);+ },function (next) {plugins.fireHook('action:group.leave', {groupName: groupName,@@ -261,6 +264,24 @@ module.exports = function (Groups) {], callback);};+ function clearGroupTitleIfSet(groupName, uid, callback) {+ if (groupName === 'registered-users' || Groups.isPrivilegeGroup(groupName)) {+ return callback();+ }+ async.waterfall([+ function (next) {+ db.getObjectField('user:' + uid, 'groupTitle', next);+ },+ function (groupTitle, next) {+ if (groupTitle === groupName) {+ db.deleteObjectField('user:' + uid, 'groupTitle', next);+ } else {+ next();+ }+ }+ ], callback);+ }+Groups.leaveAllGroups = function (uid, callback) {async.waterfall([function (next) {