Skip to content

Commit

Permalink
Dirty hack for being able to delete an expertise. Fixes #58
Browse files Browse the repository at this point in the history
The actual correction would be to provide a real authorization object, but that lead to exceptions which could not be corrected so far.
Thus, this commit provides a short-term-low-risk-workaround.
  • Loading branch information
mrsimpson committed Aug 18, 2017
1 parent 9ae2925 commit bce14bc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ Template.channelSettings.helpers({
}
});
const roomType = room && room.t;
/*
dirty hack since custom permissions create in packages/assistify-help-request/startup/customRoomTypes.js
lead to a streamer exception in some occasions.
*/
if (roomType === 'e') {
return roomType && RocketChat.authz.hasAtLeastOnePermission('delete-c');
}
return roomType && RocketChat.authz.hasAtLeastOnePermission(`delete-${ roomType }`, this.rid);
},
readOnly() {
Expand Down
7 changes: 6 additions & 1 deletion server/methods/eraseRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ Meteor.methods({
});
}

if (RocketChat.authz.hasPermission(fromId, `delete-${ room.t }`, rid)) {
/*
dirty hack since custom permissions create in packages/assistify-help-request/startup/customRoomTypes.js
lead to a streamer exception in some occasions.
*/
if ((room.t === 'e' && RocketChat.authz.hasPermission(fromId, 'delete-c', rid)) ||
RocketChat.authz.hasPermission(fromId, `delete-${ room.t }`, rid)) {
RocketChat.models.Messages.removeByRoomId(rid);
RocketChat.models.Subscriptions.removeByRoomId(rid);
return RocketChat.models.Rooms.removeById(rid);
Expand Down

0 comments on commit bce14bc

Please sign in to comment.