mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-04 14:07:35 +02:00
fixed #4277
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
var async = require('async');
|
||||
var winston = require('winston');
|
||||
var path = require('path');
|
||||
|
||||
var user = require('../../user');
|
||||
var plugins = require('../../plugins');
|
||||
@@ -73,20 +74,21 @@ module.exports = function(SocketUser) {
|
||||
user.isAdminOrSelf(socket.uid, data.uid, next);
|
||||
},
|
||||
function (next) {
|
||||
user.getUserField(data.uid, 'uploadedpicture', next);
|
||||
user.getUserFields(data.uid, ['uploadedpicture', 'picture'], next);
|
||||
},
|
||||
function(uploadedPicture, next) {
|
||||
if (!uploadedPicture.startsWith('http')) {
|
||||
require('fs').unlink(uploadedPicture, function(err) {
|
||||
function(userData, next) {
|
||||
if (!userData.uploadedpicture.startsWith('http')) {
|
||||
require('fs').unlink(path.join(__dirname, '../../../public', userData.uploadedpicture), function(err) {
|
||||
if (err) {
|
||||
winston.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
user.setUserField(data.uid, 'uploadedpicture', '', next);
|
||||
},
|
||||
function(next) {
|
||||
user.getUserField(data.uid, 'picture', next);
|
||||
|
||||
user.setUserFields(data.uid, {
|
||||
uploadedpicture: '',
|
||||
picture: userData.uploadedpicture === userData.picture ? '' : userData.picture // if current picture is uploaded picture, reset to user icon
|
||||
}, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user