PLT-7811 Standardized team sanitization flow (#7586)

* post-4.3 commit (#7581)

* reduce store boiler plate (#7585)

* fix GetPostsByIds error (#7591)

* PLT-7811 Standardized team sanitization flow

* Fixed TestGetAllTeamListings

* Stopped sanitizing teams for team admins

* Removed debug logging

* Added TearDown to sanitization tests that needed it
Этот коммит содержится в:
Harrison Healey
2017-10-09 13:30:59 -04:00
коммит произвёл Chris
родитель 9adaf53e11
Коммит e522a1c2e4
44 изменённых файлов: 1686 добавлений и 3304 удалений

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

@@ -67,6 +67,8 @@ func createTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
// Don't sanitize the team here since the user will be a team admin and their session won't reflect that yet
w.Write([]byte(rteam.ToJson()))
}
@@ -82,11 +84,10 @@ func GetAllTeamListings(c *Context, w http.ResponseWriter, r *http.Request) {
m := make(map[string]*model.Team)
for _, v := range teams {
m[v.Id] = v
if !app.SessionHasPermissionTo(c.Session, model.PERMISSION_MANAGE_SYSTEM) {
m[v.Id].Sanitize()
}
}
sanitizeTeamMap(c.Session, m)
w.Write([]byte(model.TeamMapToJson(m)))
}
@@ -112,6 +113,8 @@ func getAll(c *Context, w http.ResponseWriter, r *http.Request) {
m[v.Id] = v
}
sanitizeTeamMap(c.Session, m)
w.Write([]byte(model.TeamMapToJson(m)))
}
@@ -207,7 +210,7 @@ func addUserToTeamFromInvite(c *Context, w http.ResponseWriter, r *http.Request)
return
}
team.Sanitize()
app.SanitizeTeam(c.Session, team)
w.Write([]byte(team.ToJson()))
}
@@ -241,6 +244,8 @@ func getTeamByName(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
app.SanitizeTeam(c.Session, team)
w.Write([]byte(team.ToJson()))
return
}
@@ -294,6 +299,8 @@ func updateTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
app.SanitizeTeam(c.Session, updatedTeam)
w.Write([]byte(updatedTeam.ToJson()))
}
@@ -342,6 +349,9 @@ func getMyTeam(c *Context, w http.ResponseWriter, r *http.Request) {
return
} else {
w.Header().Set(model.HEADER_ETAG_SERVER, team.Etag())
app.SanitizeTeam(c.Session, team)
w.Write([]byte(team.ToJson()))
return
}
@@ -529,3 +539,9 @@ func getTeamMembersByIds(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
}
func sanitizeTeamMap(session model.Session, teams map[string]*model.Team) {
for _, team := range teams {
app.SanitizeTeam(session, team)
}
}