mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 16:05:49 +01:00
closes #3223
This commit is contained in:
@@ -379,8 +379,6 @@ var async = require('async'),
|
||||
db.getSortedSetRevRange('groups:visible:createtime', 0, -1, next);
|
||||
},
|
||||
function(groupNames, next) {
|
||||
groupNames.push('administrators');
|
||||
|
||||
var groupSets = groupNames.map(function(name) {
|
||||
return 'group:' + name + ':members';
|
||||
});
|
||||
|
||||
@@ -74,7 +74,8 @@ module.exports = function(Groups) {
|
||||
async.parallel([
|
||||
async.apply(db.sortedSetRemove, 'groups:visible:createtime', groupName),
|
||||
async.apply(db.sortedSetRemove, 'groups:visible:memberCount', groupName),
|
||||
async.apply(db.sortedSetRemove, 'groups:visible:name', groupName.toLowerCase() + ':' + groupName)
|
||||
async.apply(db.sortedSetRemove, 'groups:visible:name', groupName.toLowerCase() + ':' + groupName),
|
||||
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName))
|
||||
], callback);
|
||||
} else {
|
||||
db.getObjectFields('group:' + groupName, ['createtime', 'memberCount'], function(err, groupData) {
|
||||
@@ -84,7 +85,8 @@ module.exports = function(Groups) {
|
||||
async.parallel([
|
||||
async.apply(db.sortedSetAdd, 'groups:visible:createtime', groupData.createtime, groupName),
|
||||
async.apply(db.sortedSetAdd, 'groups:visible:memberCount', groupData.memberCount, groupName),
|
||||
async.apply(db.sortedSetAdd, 'groups:visible:name', 0, groupName.toLowerCase() + ':' + groupName)
|
||||
async.apply(db.sortedSetAdd, 'groups:visible:name', 0, groupName.toLowerCase() + ':' + groupName),
|
||||
async.apply(db.setObjectField, 'groupslug:groupname', utils.slugify(groupName), groupName)
|
||||
], callback);
|
||||
});
|
||||
}
|
||||
@@ -92,7 +94,22 @@ module.exports = function(Groups) {
|
||||
|
||||
Groups.hide = function(groupName, callback) {
|
||||
callback = callback || function() {};
|
||||
db.setObjectField('group:' + groupName, 'hidden', 1, callback);
|
||||
async.parallel([
|
||||
async.apply(db.setObjectField, 'group:' + groupName, 'hidden', 1),
|
||||
async.apply(updateVisibility, groupName, true)
|
||||
], function(err, results) {
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
Groups.show = function(groupName, callback) {
|
||||
callback = callback || function() {};
|
||||
async.parallel([
|
||||
async.apply(db.setObjectField, 'group:' + groupName, 'hidden', 0),
|
||||
async.apply(updateVisibility, groupName, false)
|
||||
], function(err, results) {
|
||||
callback(err);
|
||||
});
|
||||
};
|
||||
|
||||
Groups.updateCoverPosition = function(groupName, position, callback) {
|
||||
|
||||
@@ -348,15 +348,21 @@ function createAdmin(callback) {
|
||||
return retryPassword(results);
|
||||
}
|
||||
|
||||
User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
|
||||
if (err) {
|
||||
winston.warn(err.message + ' Please try again.');
|
||||
return callback(new Error('invalid-values'));
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
User.create({username: results.username, password: results.password, email: results.email}, next);
|
||||
},
|
||||
function(uid, next) {
|
||||
Groups.join('administrators', uid, next);
|
||||
},
|
||||
function(next) {
|
||||
Groups.show('administrators', next);
|
||||
}
|
||||
|
||||
Groups.join('administrators', uid, function(err) {
|
||||
callback(err, password ? results : undefined);
|
||||
});
|
||||
], function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, password ? results : undefined);
|
||||
});
|
||||
},
|
||||
retryPassword = function (originalResults) {
|
||||
|
||||
Reference in New Issue
Block a user