mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 10:46:14 +01:00
style changes
This commit is contained in:
@@ -121,11 +121,11 @@ module.exports = function (SocketUser) {
|
||||
function (next) {
|
||||
if (!reason) {
|
||||
return translator.translate('[[user:info.banned-no-reason]]', function (translated) {
|
||||
next(false, translated);
|
||||
next(null, translated);
|
||||
});
|
||||
}
|
||||
|
||||
next(false, reason);
|
||||
next(null, reason);
|
||||
},
|
||||
function (_reason, next) {
|
||||
websockets.in('uid_' + uid).emit('event:banned', {
|
||||
|
||||
@@ -67,32 +67,34 @@ module.exports = function (SocketUser) {
|
||||
};
|
||||
|
||||
function isAdminOrSelfAndPasswordMatch(uid, data, callback) {
|
||||
async.parallel({
|
||||
isAdmin: async.apply(user.isAdministrator, uid),
|
||||
hasPassword: async.apply(user.hasPassword, data.uid),
|
||||
passwordMatch: function (next) {
|
||||
if (data.password) {
|
||||
user.isPasswordCorrect(data.uid, data.password, next);
|
||||
} else {
|
||||
next(null, false);
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
isAdmin: async.apply(user.isAdministrator, uid),
|
||||
hasPassword: async.apply(user.hasPassword, data.uid),
|
||||
passwordMatch: function (next) {
|
||||
if (data.password) {
|
||||
user.isPasswordCorrect(data.uid, data.password, next);
|
||||
} else {
|
||||
next(null, false);
|
||||
}
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||
function (results, next) {
|
||||
var isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||
|
||||
if (!results.isAdmin && !isSelf) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
if (!results.isAdmin && !isSelf) {
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
if (isSelf && results.hasPassword && !results.passwordMatch) {
|
||||
return callback(new Error('[[error:invalid-password]]'));
|
||||
}
|
||||
if (isSelf && results.hasPassword && !results.passwordMatch) {
|
||||
return next(new Error('[[error:invalid-password]]'));
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
next();
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
SocketUser.changePassword = function (socket, data, callback) {
|
||||
@@ -103,20 +105,20 @@ module.exports = function (SocketUser) {
|
||||
if (!data || !data.uid) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
user.changePassword(socket.uid, data, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
events.log({
|
||||
type: 'password-change',
|
||||
uid: socket.uid,
|
||||
targetUid: data.uid,
|
||||
ip: socket.ip,
|
||||
});
|
||||
callback();
|
||||
});
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.changePassword(socket.uid, data, next);
|
||||
},
|
||||
function (next) {
|
||||
events.log({
|
||||
type: 'password-change',
|
||||
uid: socket.uid,
|
||||
targetUid: data.uid,
|
||||
ip: socket.ip,
|
||||
});
|
||||
next();
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
SocketUser.updateProfile = function (socket, data, callback) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var user = require('../../user');
|
||||
var meta = require('../../meta');
|
||||
var pagination = require('../../pagination');
|
||||
@@ -9,25 +11,29 @@ module.exports = function (SocketUser) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
}
|
||||
|
||||
if (!socket.uid && parseInt(meta.config.allowGuestUserSearching, 10) !== 1) {
|
||||
return callback(new Error('[[error:not-logged-in]]'));
|
||||
}
|
||||
user.search({
|
||||
query: data.query,
|
||||
page: data.page,
|
||||
searchBy: data.searchBy,
|
||||
sortBy: data.sortBy,
|
||||
onlineOnly: data.onlineOnly,
|
||||
bannedOnly: data.bannedOnly,
|
||||
flaggedOnly: data.flaggedOnly,
|
||||
uid: socket.uid,
|
||||
}, function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
result.pagination = pagination.create(data.page, result.pageCount);
|
||||
result['route_users:' + data.sortBy] = true;
|
||||
callback(null, result);
|
||||
});
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.search({
|
||||
query: data.query,
|
||||
page: data.page,
|
||||
searchBy: data.searchBy,
|
||||
sortBy: data.sortBy,
|
||||
onlineOnly: data.onlineOnly,
|
||||
bannedOnly: data.bannedOnly,
|
||||
flaggedOnly: data.flaggedOnly,
|
||||
uid: socket.uid,
|
||||
}, next);
|
||||
},
|
||||
function (result, next) {
|
||||
result.pagination = pagination.create(data.page, result.pageCount);
|
||||
result['route_users:' + data.sortBy] = true;
|
||||
next(null, result);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user