barisusakli 11 years ago
parent 23197af725
commit bedadd8b5f

@ -22,7 +22,12 @@ SocketUser.exists = function(socket, data, callback) {
SocketUser.deleteAccount = function(socket, data, callback) {
if (socket.uid) {
user.deleteAccount(socket.uid, callback);
user.isAdministrator(socket.uid, function(err, isAdmin) {
if (err || isAdmin) {
return callback(err || new Error('[[error:cant-delete-admin]]'));
}
user.deleteAccount(socket.uid, callback);
});
}
};

@ -25,16 +25,6 @@ module.exports = function(User) {
], callback);
};
User.deleteAccount = function(uid, callback) {
user.isAdministrator(uid, function(err, isAdmin) {
if (err || isAdmin) {
return callback(err || new Error('[[error:cant-ban-other-admins]]'));
}
deleteAccount(uid, callback);
});
};
function deletePosts(uid, callback) {
deleteSortedSetElements('uid:' + uid + ':posts', posts.purge, callback);
}
@ -53,7 +43,7 @@ module.exports = function(User) {
}, {alwaysStartAt: 0}, callback);
}
function deleteAccount(uid, callback) {
User.deleteAccount = function(uid, callback) {
user.getUserFields(uid, ['username', 'userslug', 'email'], function(err, userData) {
if (err) {
return callback(err);
@ -107,7 +97,7 @@ module.exports = function(User) {
], callback);
});
});
}
};
function deleteUserFromFollowers(uid, callback) {
db.getSetMembers('followers:' + uid, function(err, uids) {

Loading…
Cancel
Save