PLT-4710 User search now obeys privacy settings (#4673)

* Consider privacy settings in user search

* Add sysadmin as exception to privacy settings for user search
Этот коммит содержится в:
Joram Wilander
2016-12-02 12:24:22 -05:00
коммит произвёл Christopher Speller
родитель c952985ffd
Коммит ea26c72dad
3 изменённых файлов: 186 добавлений и 10 удалений

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

@@ -2648,6 +2648,21 @@ func searchUsers(c *Context, w http.ResponseWriter, r *http.Request) {
searchOptions := map[string]bool{}
searchOptions[store.USER_SEARCH_OPTION_ALLOW_INACTIVE] = props.AllowInactive
if !HasPermissionToContext(c, model.PERMISSION_MANAGE_SYSTEM) {
hideFullName := !utils.Cfg.PrivacySettings.ShowFullName
hideEmail := !utils.Cfg.PrivacySettings.ShowEmailAddress
if hideFullName && hideEmail {
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY_NO_FULL_NAME] = true
} else if hideFullName {
searchOptions[store.USER_SEARCH_OPTION_ALL_NO_FULL_NAME] = true
} else if hideEmail {
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true
}
c.Err = nil
}
var uchan store.StoreChannel
if props.InChannelId != "" {
uchan = Srv.Store.User().SearchInChannel(props.InChannelId, props.Term, searchOptions)
@@ -2711,7 +2726,14 @@ func autocompleteUsersInChannel(c *Context, w http.ResponseWriter, r *http.Reque
}
searchOptions := map[string]bool{}
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true
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().SearchInChannel(channelId, term, searchOptions)
nuchan := Srv.Store.User().SearchNotInChannel(teamId, channelId, term, searchOptions)
@@ -2760,7 +2782,14 @@ func autocompleteUsersInTeam(c *Context, w http.ResponseWriter, r *http.Request)
}
searchOptions := map[string]bool{}
searchOptions[store.USER_SEARCH_OPTION_NAMES_ONLY] = true
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(teamId, term, searchOptions)