summaryrefslogtreecommitdiffstats
path: root/api/user.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-12-02 12:24:22 -0500
committerChristopher Speller <crspeller@gmail.com>2016-12-02 12:24:22 -0500
commitea26c72dad3bc1a2ccb020310b635bd6484a1b15 (patch)
treeec73bb8521deb49fbd08033ef0543c2f0311cdda /api/user.go
parentc952985ffd035f95e82fef2fbc2e8bd48ab9ec3b (diff)
downloadchat-ea26c72dad3bc1a2ccb020310b635bd6484a1b15.tar.gz
chat-ea26c72dad3bc1a2ccb020310b635bd6484a1b15.tar.bz2
chat-ea26c72dad3bc1a2ccb020310b635bd6484a1b15.zip
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
Diffstat (limited to 'api/user.go')
-rw-r--r--api/user.go33
1 files changed, 31 insertions, 2 deletions
diff --git a/api/user.go b/api/user.go
index f5f2582b3..e5d00ea36 100644
--- a/api/user.go
+++ b/api/user.go
@@ -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)