mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Don't autocomplete users by email (#4896)
This commit is contained in:
committed by
Christopher Speller
parent
fa046ccf06
commit
6f4e6386fb
12
api/user.go
12
api/user.go
@@ -2859,7 +2859,17 @@ func autocompleteUsersInTeam(c *Context, w http.ResponseWriter, r *http.Request)
|
||||
func autocompleteUsers(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
term := r.URL.Query().Get("term")
|
||||
|
||||
uchan := Srv.Store.User().Search("", term, map[string]bool{})
|
||||
searchOptions := map[string]bool{}
|
||||
|
||||
hideFullName := !utils.Cfg.PrivacySettings.ShowFullName
|
||||
if hideFullName && !HasPermissionToContext(c, model.PERMISSION_MANAGE_SYSTEM) {
|
||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
|
||||
c.Err = nil
|
||||
} else {
|
||||
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true
|
||||
}
|
||||
|
||||
uchan := Srv.Store.User().Search("", term, searchOptions)
|
||||
|
||||
var profiles []*model.User
|
||||
|
||||
|
||||
@@ -2387,6 +2387,15 @@ func TestAutocompleteUsers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if result, err := Client.AutocompleteUsers("amazonses"); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
users := result.Data.([]*model.User)
|
||||
if len(users) != 0 {
|
||||
t.Fatal("should have returned 0 users - email should not autocomplete")
|
||||
}
|
||||
}
|
||||
|
||||
if result, err := Client.AutocompleteUsers(""); err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user