Skip to content
Snippets Groups Projects
Unverified Commit b618e77d authored by Bradley Hilton's avatar Bradley Hilton
Browse files

Fix files uploaded by other users not being able to be deleted by users with permission

parent 1bae5c52
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,9 @@ Meteor.methods({ ...@@ -7,6 +7,9 @@ Meteor.methods({
return false; return false;
} }
//We're now only passed in the `_id` property to lower the amount of data sent to the server
message = ChatMessage.findOne({ _id: message._id });
const hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid); const hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid);
const deleteAllowed = RocketChat.settings.get('Message_AllowDeleting'); const deleteAllowed = RocketChat.settings.get('Message_AllowDeleting');
let deleteOwn = false; let deleteOwn = false;
......
...@@ -9,7 +9,7 @@ UploadFS.config.defaultStorePermissions = new UploadFS.StorePermissions({ ...@@ -9,7 +9,7 @@ UploadFS.config.defaultStorePermissions = new UploadFS.StorePermissions({
return userId === doc.userId; return userId === doc.userId;
}, },
remove: function(userId, doc) { remove: function(userId, doc) {
return userId === doc.userId; return RocketChat.authz.hasPermission(Meteor.userId(), 'delete-message', doc.rid) || (RocketChat.settings.get('Message_AllowDeleting') && userId === doc.userId);
} }
}); });
......
...@@ -253,7 +253,7 @@ class @ChatMessages ...@@ -253,7 +253,7 @@ class @ChatMessages
toastr.error(t('Message_deleting_blocked')) toastr.error(t('Message_deleting_blocked'))
return return
Meteor.call 'deleteMessage', message, (error, result) -> Meteor.call 'deleteMessage', { _id: message._id }, (error, result) ->
if error if error
return handleError(error) return handleError(error)
......
/* global FileUpload */
Meteor.methods({ Meteor.methods({
deleteFileMessage: function(fileID) { deleteFileMessage: function(fileID) {
check(fileID, String); check(fileID, String);
return Meteor.call('deleteMessage', RocketChat.models.Messages.getMessageByFileId(fileID)); const msg = RocketChat.models.Messages.getMessageByFileId(fileID);
if (msg) {
return Meteor.call('deleteMessage', msg);
}
return FileUpload.delete(fileID);
} }
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment