summaryrefslogtreecommitdiffstats
path: root/api4/user.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-04-17 18:39:08 -0400
committerChristopher Speller <crspeller@gmail.com>2018-04-17 15:39:08 -0700
commitb15f69ea30c022a49a6716d4fb456a73bae7b875 (patch)
treee65ea47f55c9aa928692c7fb1ddfc9a4a6f084e9 /api4/user.go
parent51a6e95f58abd65b454e365d45a510eefd84bfe3 (diff)
downloadchat-b15f69ea30c022a49a6716d4fb456a73bae7b875.tar.gz
chat-b15f69ea30c022a49a6716d4fb456a73bae7b875.tar.bz2
chat-b15f69ea30c022a49a6716d4fb456a73bae7b875.zip
Handle app errors in user autocomplete endpoint (#8643)
Diffstat (limited to 'api4/user.go')
-rw-r--r--api4/user.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/api4/user.go b/api4/user.go
index 9aa709db5..f5c56656c 100644
--- a/api4/user.go
+++ b/api4/user.go
@@ -508,7 +508,12 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- result, _ := c.App.AutocompleteUsersInChannel(teamId, channelId, name, searchOptions, c.IsSystemAdmin())
+ result, err := c.App.AutocompleteUsersInChannel(teamId, channelId, name, searchOptions, c.IsSystemAdmin())
+ if err != nil {
+ c.Err = err
+ return
+ }
+
autocomplete.Users = result.InChannel
autocomplete.OutOfChannel = result.OutOfChannel
} else if len(teamId) > 0 {
@@ -517,11 +522,20 @@ func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
- result, _ := c.App.AutocompleteUsersInTeam(teamId, name, searchOptions, c.IsSystemAdmin())
+ result, err := c.App.AutocompleteUsersInTeam(teamId, name, searchOptions, c.IsSystemAdmin())
+ if err != nil {
+ c.Err = err
+ return
+ }
+
autocomplete.Users = result.InTeam
} else {
// No permission check required
- result, _ := c.App.SearchUsersInTeam("", name, searchOptions, c.IsSystemAdmin())
+ result, err := c.App.SearchUsersInTeam("", name, searchOptions, c.IsSystemAdmin())
+ if err != nil {
+ c.Err = err
+ return
+ }
autocomplete.Users = result
}