From 1913c77181da42d4cf814e33e70446a99f9866e0 Mon Sep 17 00:00:00 2001 From: Sing Li Date: Tue, 28 Jul 2015 15:57:29 -0400 Subject: [PATCH] fix prob when room id is not valid --- server/methods/canAccessRoom.coffee | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/server/methods/canAccessRoom.coffee b/server/methods/canAccessRoom.coffee index 1b4a30f11292..d1a099294e7e 100644 --- a/server/methods/canAccessRoom.coffee +++ b/server/methods/canAccessRoom.coffee @@ -12,12 +12,15 @@ Meteor.methods room = ChatRoom.findOne rid, { fields: { usernames: 1, t: 1, name: 1 } } - if room.t is 'c' - canAccess = true - else if room.usernames.indexOf(user.username) isnt -1 - canAccess = true + if room + if room.t is 'c' + canAccess = true + else if room.usernames.indexOf(user.username) isnt -1 + canAccess = true - if canAccess isnt true - return false + if canAccess isnt true + return false + else + return _.pick room, ['_id', 't', 'name'] else - return _.pick room, ['_id', 't', 'name'] + throw new Meteor.Error 'invalid-room', '[methods] canAccessRoom -> Room ID is invalid'