Fix API Get channels for a user returns users' dm channels with blank teamid (#4748)

* fix API Get channels for a user returns users' dm channels with blank team ID

add check in the context.go

add suggestion

made adjustment per review and support from @joram

* update tests

* add check if needd user or admin permissions

* update per review
Этот коммит содержится в:
Carlos Tadeu Panato Junior
2016-12-20 16:55:22 +01:00
коммит произвёл Corey Hulen
родитель 92b2810d84
Коммит b9092ca2f5
5 изменённых файлов: 45 добавлений и 11 удалений

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

@@ -431,10 +431,13 @@ func updateChannelPurpose(c *Context, w http.ResponseWriter, r *http.Request) {
}
func getChannels(c *Context, w http.ResponseWriter, r *http.Request) {
if c.TeamId == "" {
c.Err = model.NewLocAppError("", "api.context.missing_teamid.app_error", nil, "TeamIdRequired")
c.Err.StatusCode = http.StatusBadRequest
return
}
// user is already in the team
// Get's all channels the user is a member of
if result := <-Srv.Store.Channel().GetChannels(c.TeamId, c.Session.UserId); result.Err != nil {
if result.Err.Id == "store.sql_channel.get_channels.not_found.app_error" {
// lets make sure the user is valid