MM-12192: autocompleteUsers: if a teamId is provided, require it to match the channel's team id (#9481)

* MM-12192: unit test

* MM-1292: autocompleteUsers: if a teamId is provided, require it to match the channel's team id
Этот коммит содержится в:
Jesse Hallam
2018-09-28 10:06:40 -04:00
коммит произвёл Harrison Healey
родитель de5c8622f8
Коммит ee672a72e4
3 изменённых файлов: 23 добавлений и 0 удалений

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

@@ -533,6 +533,20 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// If a teamId is provided, require it to match the channel's team id.
if teamId != "" {
channel, err := c.App.GetChannel(channelId)
if err != nil {
c.Err = err
return
}
if channel.TeamId != teamId {
c.Err = model.NewAppError("autocompleteUsers", "api.user.autocomplete_users.invalid_team_id", nil, "", http.StatusUnauthorized)
return
}
}
result, err := c.App.AutocompleteUsersInChannel(teamId, channelId, name, searchOptions, c.IsSystemAdmin())
if err != nil {
c.Err = err