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

Don't allow changing the room type if you only have permission to create one and not the other

parent 7ccbc15d
No related branches found
No related tags found
No related merge requests found
......@@ -143,7 +143,14 @@ Template.channelSettings.onCreated ->
options:
c: 'Channel'
p: 'Private_Group'
canView: (room) => room.t in ['c', 'p']
canView: (room) ->
if not room.t in ['c', 'p']
return false
else if room.t is 'p' and not RocketChat.authz.hasAllPermission('create-c')
return false
else if room.t is 'c' and not RocketChat.authz.hasAllPermission('create-p')
return false
return true
canEdit: (room) => RocketChat.authz.hasAllPermission('edit-room', room._id)
save: (value, room) ->
if value not in ['c', 'p']
......
......@@ -17,6 +17,12 @@ Meteor.methods
room = RocketChat.models.Rooms.findOneById rid
if room?
if setting is 'roomType' and value isnt room.t and value is 'c' and not RocketChat.authz.hasPermission(@userId, 'create-c')
throw new Meteor.Error 'error-action-not-allowed', 'Changing a private group to a public channel is not allowed', { method: 'saveRoomSettings', action: 'Change_Room_Type' }
if setting is 'roomType' and value isnt room.t and value is 'p' and not RocketChat.authz.hasPermission(@userId, 'create-p')
throw new Meteor.Error 'error-action-not-allowed', 'Changing a public channel to a private room is not allowed', { method: 'saveRoomSettings', action: 'Change_Room_Type' }
switch setting
when 'roomName'
name = RocketChat.saveRoomName rid, value, Meteor.user()
......
......@@ -252,6 +252,7 @@
"CDN_PREFIX": "CDN Prefix",
"Certificates_and_Keys": "Certificates and Keys",
"Changing_email": "Changing email",
"Change_Room_Type": "Changing the Room Type",
"channel": "channel",
"Channel": "Channel",
"Channel_already_exist": "The channel '#%s' already exists.",
......
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