mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #747
This commit is contained in:
@@ -187,18 +187,13 @@ define(function() {
|
|||||||
var username = $('#search-user').val();
|
var username = $('#search-user').val();
|
||||||
|
|
||||||
jQuery('.fa-spinner').removeClass('none');
|
jQuery('.fa-spinner').removeClass('none');
|
||||||
socket.emit('api:admin.user.search', username);
|
|
||||||
|
|
||||||
}, 250);
|
socket.emit('api:admin.user.search', username, function(err, data) {
|
||||||
});
|
console.log(data);
|
||||||
|
if(err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
initUsers();
|
|
||||||
|
|
||||||
handleUserCreate();
|
|
||||||
|
|
||||||
socket.removeAllListeners('api:admin.user.search');
|
|
||||||
|
|
||||||
socket.on('api:admin.user.search', function(data) {
|
|
||||||
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
||||||
users: data
|
users: data
|
||||||
}),
|
}),
|
||||||
@@ -221,6 +216,12 @@ define(function() {
|
|||||||
|
|
||||||
initUsers();
|
initUsers();
|
||||||
});
|
});
|
||||||
|
}, 250);
|
||||||
|
});
|
||||||
|
|
||||||
|
initUsers();
|
||||||
|
|
||||||
|
handleUserCreate();
|
||||||
|
|
||||||
function onUsersLoaded(users) {
|
function onUsersLoaded(users) {
|
||||||
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
var html = templates.prepare(templates['admin/users'].blocks['users']).parse({
|
||||||
|
|||||||
@@ -47,16 +47,13 @@ define(function() {
|
|||||||
jQuery('#user-notfound-notify').html('<i class="fa fa-spinner fa-spin"></i>');
|
jQuery('#user-notfound-notify').html('<i class="fa fa-spinner fa-spin"></i>');
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
socket.emit('api:admin.user.search', username);
|
socket.emit('api:admin.user.search', username, function(err, data) {
|
||||||
}, 500); //replace this with global throttling function/constant
|
console.log(err, data);
|
||||||
|
if(err) {
|
||||||
|
return app.alert(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
}, 250);
|
if (!data) {
|
||||||
});
|
|
||||||
|
|
||||||
socket.removeAllListeners('api:admin.user.search');
|
|
||||||
|
|
||||||
socket.on('api:admin.user.search', function(data) {
|
|
||||||
if (data === null) {
|
|
||||||
$('#user-notfound-notify').html('You need to be logged in to search!');
|
$('#user-notfound-notify').html('You need to be logged in to search!');
|
||||||
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
$('#user-notfound-notify').parent().addClass('btn-warning label-warning');
|
||||||
return;
|
return;
|
||||||
@@ -79,6 +76,10 @@ define(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
}, 500); //replace this with global throttling function/constant
|
||||||
|
|
||||||
|
}, 250);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('api:user.isOnline', function(data) {
|
socket.on('api:user.isOnline', function(data) {
|
||||||
if(getActiveSection() == 'online' && !loadingMoreUsers) {
|
if(getActiveSection() == 'online' && !loadingMoreUsers) {
|
||||||
|
|||||||
@@ -487,9 +487,9 @@ var bcrypt = require('bcrypt'),
|
|||||||
|
|
||||||
User.search = function(username, callback) {
|
User.search = function(username, callback) {
|
||||||
if (!username) {
|
if (!username) {
|
||||||
callback([]);
|
return callback([]);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db.search('user', username, function(err, uids) {
|
db.search('user', username, function(err, uids) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|||||||
@@ -1056,15 +1056,30 @@ websockets.init = function(io) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:admin.user.search', function(username, callback) {
|
socket.on('api:admin.user.search', function(username, callback) {
|
||||||
if (uid && uid > 0) {
|
if (!(uid && uid > 0)) {
|
||||||
user.search(username, function(data) {
|
return callback();
|
||||||
if (!callback) socket.emit('api:admin.user.search', data);
|
|
||||||
else callback(null, data);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (!callback) socket.emit('api:admin.user.search', null);
|
|
||||||
else callback();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user.search(username, function(data) {
|
||||||
|
function isAdmin(userData, next) {
|
||||||
|
user.isAdministrator(userData.uid, function(err, isAdmin) {
|
||||||
|
if(err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
userData.administrator = isAdmin?'1':'0';
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async.each(data, isAdmin, function(err) {
|
||||||
|
if(err) {
|
||||||
|
return callback({message: err.message});
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(null, data);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:admin.categories.search', function(username, cid, callback) {
|
socket.on('api:admin.categories.search', function(username, cid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user