Don't allow users to be added to a channel they are not in the team of (#3246)

Этот коммит содержится в:
Joram Wilander
2016-06-04 10:52:25 -04:00
родитель 8d09c58b4d
Коммит 971149d2b2
6 изменённых файлов: 32 добавлений и 8 удалений

Просмотреть файл

@@ -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 {