summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-06-04 10:52:25 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-06-04 10:52:25 -0400
commit971149d2b298b3408af7218c868ed0b3edd83c2e (patch)
tree86e082c9341ccd98bc6bf5894ce3ee7d14359550 /api/channel.go
parent8d09c58b4dbfd9f9ad651e03263dc109d7680a47 (diff)
downloadchat-971149d2b298b3408af7218c868ed0b3edd83c2e.tar.gz
chat-971149d2b298b3408af7218c868ed0b3edd83c2e.tar.bz2
chat-971149d2b298b3408af7218c868ed0b3edd83c2e.zip
Don't allow users to be added to a channel they are not in the team of (#3246)
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/api/channel.go b/api/channel.go
index ba6de1a48..6d1604900 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -512,8 +512,15 @@ func AddUserToChannel(user *model.User, channel *model.Channel) (*model.ChannelM
return nil, model.NewLocAppError("AddUserToChannel", "api.channel.add_user_to_channel.type.app_error", nil, "")
}
- if result := <-Srv.Store.Channel().GetMember(channel.Id, user.Id); result.Err != nil {
- if result.Err.Id != store.MISSING_MEMBER_ERROR {
+ tmchan := Srv.Store.Team().GetMember(channel.TeamId, user.Id)
+ cmchan := Srv.Store.Channel().GetMember(channel.Id, user.Id)
+
+ if result := <-tmchan; result.Err != nil {
+ return nil, result.Err
+ }
+
+ if result := <-cmchan; result.Err != nil {
+ if result.Err.Id != store.MISSING_CHANNEL_MEMBER_ERROR {
return nil, result.Err
}
} else {