Sorting 'Group By Type' hides private rooms
Description:
After updating to version 62.1 users complained about not seeing private rooms. I did not have the issue so I searched for the cause. I found out that it was an issue with the user permissions. All users have to have the permission 'view-p-room'. If the sorting is not set to 'group by type' the users can access their private rooms even if they do not have this permission.
Server Setup Information:
- Version of Rocket.Chat Server: 62.1
- Operating System: ubuntu
- Deployment Method(snap/docker/tar/etc): tar
- Number of Running Instances: 1
- DB Replicaset Oplog: disabled
- Node Version: 8.9.4
- mongoDB Version: 3.4.13
Steps to Reproduce:
- uncheck the permission 'view-p-room' for users
- set sorting to 'group by type'
- all private channels are hidden
Expected behavior:
Actual behavior:
Relevant logs:
~According to [1], this is expected behavior, I can't answer for sure though.~
I'd like someone to explain to me why this was designed this way (I won't mention the original author of the CoffeScript version because he seems to be away from Github for quite some time), because this is what I'm getting:
-
If
userrole has permissionview-p-room- Expected behavior: User can see his private rooms merged and grouped by type.
- Expected behavior after reading code linked above: User can see private rooms only when channels are merged (not grouped by type), because of the
ifsection highlighted on [1]. - Actual behavior: User can see his private rooms merged and grouped by type. (Expected).
-
If
userrole does not have permissionview-p-room- Expected behavior: User can't see neither access private rooms
- Expected behavior after reading code linked above: User can't see neither access private rooms, because
RocketChat.authz.hasPermission(Meteor.userId(), 'view-p-room')will return false. - Actual behavior: User can see his private rooms when channels are merged, but not grouped by type.
If I remove the if highlighted by [1] and always push, normal users without the view-p-room permission can normally see their private rooms, which makes me think that RocketChat.authz.hasPermission(Meteor.userId(), 'view-p-room') could be faulty because this section of the code shouldn't be executed at all.
[1] :https://github.com/RocketChat/Rocket.Chat/blob/6cf49c0c396d73f9a52e692cc5968a5995f70475/server/methods/channelsList.js#L69
@willihelm it was fixed in v0.63.1.