From 1ab7034574de2229d3cfc49391e6579db37a3064 Mon Sep 17 00:00:00 2001 From: Antti Ahti Date: Wed, 14 Oct 2015 18:27:03 +0300 Subject: Use team display name in team switcher menu - /teams/find_teams returns team objects instead of just team names - use display_name in UI instead of name in the team switch menu --- api/team.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'api/team.go') diff --git a/api/team.go b/api/team.go index 6aa5ec1bb..7148caac3 100644 --- a/api/team.go +++ b/api/team.go @@ -409,14 +409,12 @@ func findTeams(c *Context, w http.ResponseWriter, r *http.Request) { return } else { teams := result.Data.([]*model.Team) - - s := make([]string, 0, len(teams)) - + m := make(map[string]*model.Team) for _, v := range teams { - s = append(s, v.Name) + m[v.Id] = v } - w.Write([]byte(model.ArrayToJson(s))) + w.Write([]byte(model.TeamMapToJson(m))) } } -- cgit v1.2.3-1-g7c22 From 731595c1a93e51bcd4e6034b088b53766883a9eb Mon Sep 17 00:00:00 2001 From: Antti Ahti Date: Wed, 14 Oct 2015 18:31:58 +0300 Subject: Fix typo (isTreamCreationAllowed -> isTeamCreationAllowed) --- api/team.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'api/team.go') diff --git a/api/team.go b/api/team.go index 7148caac3..18acf33ce 100644 --- a/api/team.go +++ b/api/team.go @@ -52,7 +52,7 @@ func signupTeam(c *Context, w http.ResponseWriter, r *http.Request) { return } - if !isTreamCreationAllowed(c, email) { + if !isTeamCreationAllowed(c, email) { return } @@ -100,7 +100,7 @@ func createTeamFromSSO(c *Context, w http.ResponseWriter, r *http.Request) { return } - if !isTreamCreationAllowed(c, team.Email) { + if !isTeamCreationAllowed(c, team.Email) { return } @@ -169,7 +169,7 @@ func createTeamFromSignup(c *Context, w http.ResponseWriter, r *http.Request) { return } - if !isTreamCreationAllowed(c, teamSignup.Team.Email) { + if !isTeamCreationAllowed(c, teamSignup.Team.Email) { return } @@ -257,7 +257,7 @@ func CreateTeam(c *Context, team *model.Team) *model.Team { return nil } - if !isTreamCreationAllowed(c, team.Email) { + if !isTeamCreationAllowed(c, team.Email) { return nil } @@ -276,12 +276,12 @@ func CreateTeam(c *Context, team *model.Team) *model.Team { } } -func isTreamCreationAllowed(c *Context, email string) bool { +func isTeamCreationAllowed(c *Context, email string) bool { email = strings.ToLower(email) if !utils.Cfg.TeamSettings.EnableTeamCreation { - c.Err = model.NewAppError("isTreamCreationAllowed", "Team creation has been disabled. Please ask your systems administrator for details.", "") + c.Err = model.NewAppError("isTeamCreationAllowed", "Team creation has been disabled. Please ask your systems administrator for details.", "") return false } @@ -298,7 +298,7 @@ func isTreamCreationAllowed(c *Context, email string) bool { } if len(utils.Cfg.TeamSettings.RestrictCreationToDomains) > 0 && !matched { - c.Err = model.NewAppError("isTreamCreationAllowed", "Email must be from a specific domain (e.g. @example.com). Please ask your systems administrator for details.", "") + c.Err = model.NewAppError("isTeamCreationAllowed", "Email must be from a specific domain (e.g. @example.com). Please ask your systems administrator for details.", "") return false } -- cgit v1.2.3-1-g7c22 From 8f96db4d0b52d0701398703364948e659f3ce34f Mon Sep 17 00:00:00 2001 From: Antti Ahti Date: Wed, 14 Oct 2015 19:27:19 +0300 Subject: Sanitize team data We don't want to expose sensitive data that might pose a security risk. --- api/team.go | 1 + 1 file changed, 1 insertion(+) (limited to 'api/team.go') diff --git a/api/team.go b/api/team.go index 18acf33ce..f6038566a 100644 --- a/api/team.go +++ b/api/team.go @@ -411,6 +411,7 @@ func findTeams(c *Context, w http.ResponseWriter, r *http.Request) { teams := result.Data.([]*model.Team) m := make(map[string]*model.Team) for _, v := range teams { + v.Sanitize() m[v.Id] = v } -- cgit v1.2.3-1-g7c22