summaryrefslogtreecommitdiffstats
path: root/api4/user.go
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2017-03-29 21:11:40 -0400
committerJoram Wilander <jwawilander@gmail.com>2017-03-29 21:11:40 -0400
commit6ac87d82e38c83e3b9b3bd12c3122e047f0110b1 (patch)
treeaa3f0f8f41df7c987f8bb62756ca3d8259ecbaa1 /api4/user.go
parenta4764a5c10ec59820eec7338d97be48d41c1a4d6 (diff)
downloadchat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.tar.gz
chat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.tar.bz2
chat-6ac87d82e38c83e3b9b3bd12c3122e047f0110b1.zip
PLT-2713 Added ability for admins to list users not in any team (#5844)
* PLT-2713 Added ability for admins to list users not in any team * Updated style of unit test
Diffstat (limited to 'api4/user.go')
-rw-r--r--api4/user.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/api4/user.go b/api4/user.go
index 298c5cc8d..e4595ee54 100644
--- a/api4/user.go
+++ b/api4/user.go
@@ -269,6 +269,7 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
notInTeamId := r.URL.Query().Get("not_in_team")
inChannelId := r.URL.Query().Get("in_channel")
notInChannelId := r.URL.Query().Get("not_in_channel")
+ withoutTeam := r.URL.Query().Get("without_team")
if len(notInChannelId) > 0 && len(inTeamId) == 0 {
c.SetInvalidParam("team_id")
@@ -279,7 +280,15 @@ func getUsers(c *Context, w http.ResponseWriter, r *http.Request) {
var err *model.AppError
etag := ""
- if len(notInChannelId) > 0 {
+ if withoutTeamBool, err := strconv.ParseBool(withoutTeam); err == nil && withoutTeamBool {
+ // Use a special permission for now
+ if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_LIST_USERS_WITHOUT_TEAM) {
+ c.SetPermissionError(model.PERMISSION_LIST_USERS_WITHOUT_TEAM)
+ return
+ }
+
+ profiles, err = app.GetUsersWithoutTeamPage(c.Params.Page, c.Params.PerPage, c.IsSystemAdmin())
+ } else if len(notInChannelId) > 0 {
if !app.SessionHasPermissionToChannel(c.Session, notInChannelId, model.PERMISSION_READ_CHANNEL) {
c.SetPermissionError(model.PERMISSION_READ_CHANNEL)
return