Skip to content
Snippets Groups Projects
Commit e62fe6ea authored by Gabriel Engel's avatar Gabriel Engel Committed by GitHub
Browse files

Merge pull request #5143 from RocketChat/fix-being-able-to-create-public-room

Don't allow changing the room type no other permission
parents 7ccbc15d bbf0884a
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