From c5eb95b57aff4e9bf791030e5ffe26c27656e70f Mon Sep 17 00:00:00 2001 From: Marcelo Schmidt Date: Fri, 29 Apr 2016 13:42:11 -0300 Subject: [PATCH] Fix getRoomIdByNameOrId to allow getting id from joined room --- server/methods/getRoomIdByNameOrId.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/methods/getRoomIdByNameOrId.coffee b/server/methods/getRoomIdByNameOrId.coffee index 42ddad51275..bf94408cd2f 100644 --- a/server/methods/getRoomIdByNameOrId.coffee +++ b/server/methods/getRoomIdByNameOrId.coffee @@ -3,7 +3,10 @@ Meteor.methods room = RocketChat.models.Rooms.findOneById(rid) or RocketChat.models.Rooms.findOneByName(rid) + if room.usernames.indexOf(Meteor.user()?.username) isnt -1 + return room._id + if room?.t isnt 'c' or RocketChat.authz.hasPermission(Meteor.userId(), 'view-c-room') isnt true - throw new Meteor.Error 'error-not-allowed', 'Not allowed', { method: 'joinRoom' } + throw new Meteor.Error 'error-not-allowed', 'Not allowed', { method: 'getRoomIdByNameOrId' } return room._id