mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
fixing issue where after a user changed their username, the new name was not reindexed by Reds
This commit is contained in:
@@ -115,7 +115,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
module.searchRemove = function(key, id) {
|
||||
module.searchRemove = function(key, id, callback) {
|
||||
if(key === 'post') {
|
||||
postSearch.remove(id);
|
||||
} else if(key === 'topic') {
|
||||
@@ -123,6 +123,10 @@
|
||||
} else if(key === 'user') {
|
||||
userSearch.remove(id);
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
module.flushdb = function(callback) {
|
||||
|
||||
@@ -77,16 +77,10 @@ SocketAdmin.user.banUser = function(theirid, sessionData) {
|
||||
};
|
||||
|
||||
SocketAdmin.user.unbanUser = function(theirid, sessionData) {
|
||||
if (sessionData.uid && sessionData.uid > 0) {
|
||||
admin.user.unbanUser(sessionData.uid, theirid, sessionData.socket);
|
||||
}
|
||||
};
|
||||
|
||||
SocketAdmin.user.search = function(username, callback, sessionData) {
|
||||
if (!(sessionData.uid && sessionData.uid > 0)) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
user.search(username, function(data) {
|
||||
function isAdmin(userData, next) {
|
||||
user.isAdministrator(userData.uid, function(err, isAdmin) {
|
||||
@@ -124,7 +118,6 @@ SocketAdmin.categories.update = function(data, sessionData) {
|
||||
};
|
||||
|
||||
SocketAdmin.categories.search = function(username, cid, callback, sessionData) {
|
||||
if (sessionData.uid && sessionData.uid > 0) {
|
||||
user.search(username, function(data) {
|
||||
async.map(data, function(userObj, next) {
|
||||
CategoryTools.privileges(cid, userObj.uid, function(err, privileges) {
|
||||
@@ -144,13 +137,6 @@ SocketAdmin.categories.search = function(username, cid, callback, sessionData) {
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (!callback) {
|
||||
sessionData.socket.emit('api:admin.user.search', null);
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SocketAdmin.categories.setPrivilege = function(cid, uid, privilege, set, callback) {
|
||||
|
||||
19
src/user.js
19
src/user.js
@@ -309,10 +309,8 @@ var bcrypt = require('bcrypt'),
|
||||
User.setUserField(uid, 'username', data.username);
|
||||
db.deleteObjectField('username:uid', userData.username);
|
||||
db.setObjectField('username:uid', data.username, uid);
|
||||
db.searchRemove('user', uid, function() {
|
||||
db.searchIndex('user', data.username, uid);
|
||||
});
|
||||
events.logUsernameChange(uid, userData.username, data.username);
|
||||
User.reIndexUser(uid, data.username);
|
||||
}
|
||||
|
||||
if(userslug !== userData.userslug) {
|
||||
@@ -451,19 +449,20 @@ var bcrypt = require('bcrypt'),
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
function reIndexUser(uid, username) {
|
||||
db.searchRemove('user', uid, function() {
|
||||
db.searchIndex('user', username, uid);
|
||||
});
|
||||
for (var i = 0; i < usersData.length; ++i) {
|
||||
User.reIndexUser(usersData[i].uid, usersData[i].username);
|
||||
}
|
||||
|
||||
for (var i = 0; i < usersData.length; ++i) {
|
||||
reIndexUser(usersData[i].uid, usersData[i].username);
|
||||
}
|
||||
callback(null, 1);
|
||||
});
|
||||
};
|
||||
|
||||
User.reIndexUser = function(uid, username) {
|
||||
db.searchRemove('user', uid, function() {
|
||||
db.searchIndex('user', username, uid);
|
||||
});
|
||||
};
|
||||
|
||||
// thanks to @akhoury
|
||||
User.getUsersCSV = function(callback) {
|
||||
var csvContent = "";
|
||||
|
||||
Reference in New Issue
Block a user