Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix prob when room id is not valid #360

Merged
merged 1 commit into from
Jul 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions server/methods/canAccessRoom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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'