mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-26 01:09:56 +01:00
closes #5219
This commit is contained in:
@@ -5,6 +5,7 @@ var fs = require('fs');
|
||||
var async = require('async');
|
||||
var semver = require('semver');
|
||||
var winston = require('winston');
|
||||
var colors = require('colors');
|
||||
|
||||
var pkg = require('../../package.json');
|
||||
|
||||
@@ -15,7 +16,7 @@ module.exports = function (Meta) {
|
||||
var modules = Object.keys(pkg.dependencies);
|
||||
var depsOutdated = false;
|
||||
var depsMissing = false;
|
||||
|
||||
|
||||
winston.verbose('Checking dependencies for outdated modules');
|
||||
|
||||
async.every(modules, function (module, next) {
|
||||
|
||||
@@ -28,18 +28,14 @@ module.exports = function (SocketUser) {
|
||||
if (!socket.uid) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
user.isAdministrator(socket.uid, function (err, isAdmin) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.isAdminOrSelf(socket.uid, data.uid, next);
|
||||
},
|
||||
function (next) {
|
||||
user.updateCoverPicture(data, next);
|
||||
}
|
||||
|
||||
if (!isAdmin && data.uid !== socket.uid) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
user.updateCoverPicture(data, callback);
|
||||
});
|
||||
], callback);
|
||||
};
|
||||
|
||||
SocketUser.removeCover = function (socket, data, callback) {
|
||||
@@ -47,12 +43,14 @@ module.exports = function (SocketUser) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
user.isAdminOrSelf(socket.uid, data.uid, function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.isAdminOrSelf(socket.uid, data.uid, next);
|
||||
},
|
||||
function (next) {
|
||||
user.removeCoverPicture(data, next);
|
||||
}
|
||||
user.removeCoverPicture(data, callback);
|
||||
});
|
||||
], callback);
|
||||
};
|
||||
|
||||
function isAdminOrSelfAndPasswordMatch(uid, data, callback) {
|
||||
@@ -70,13 +68,13 @@ module.exports = function (SocketUser) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var self = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||
var isSelf = parseInt(uid, 10) === parseInt(data.uid, 10);
|
||||
|
||||
if (!results.isAdmin && !self) {
|
||||
if (!results.isAdmin && !isSelf) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
|
||||
if (self && results.hasPassword && !results.passwordMatch) {
|
||||
if (isSelf && results.hasPassword && !results.passwordMatch) {
|
||||
return callback(new Error('[[error:invalid-password]]'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user