MM-10980: Conditionally filteres User json properties. (#9018)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
e51ae39766
Коммит
56ba06c016
@@ -153,8 +153,12 @@ func getUserByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if c.HandleEtag(etag, "Get User", w, r) {
|
if c.HandleEtag(etag, "Get User", w, r) {
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
if c.Session.UserId == user.Id {
|
||||||
|
user.Sanitize(map[string]bool{})
|
||||||
} else {
|
} else {
|
||||||
c.App.SanitizeProfile(user, c.IsSystemAdmin())
|
c.App.SanitizeProfile(user, c.IsSystemAdmin())
|
||||||
|
}
|
||||||
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
w.Header().Set(model.HEADER_ETAG_SERVER, etag)
|
||||||
w.Write([]byte(user.ToJson()))
|
w.Write([]byte(user.ToJson()))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ func TestGetUserByUsername(t *testing.T) {
|
|||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowEmailAddress = false })
|
||||||
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false })
|
th.App.UpdateConfig(func(cfg *model.Config) { cfg.PrivacySettings.ShowFullName = false })
|
||||||
|
|
||||||
ruser, resp = Client.GetUserByUsername(user.Username, "")
|
ruser, resp = Client.GetUserByUsername(th.BasicUser2.Username, "")
|
||||||
CheckNoError(t, resp)
|
CheckNoError(t, resp)
|
||||||
|
|
||||||
if ruser.Email != "" {
|
if ruser.Email != "" {
|
||||||
@@ -424,6 +424,12 @@ func TestGetUserByUsername(t *testing.T) {
|
|||||||
t.Fatal("last name should be blank")
|
t.Fatal("last name should be blank")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ruser, resp = Client.GetUserByUsername(th.BasicUser.Username, "")
|
||||||
|
CheckNoError(t, resp)
|
||||||
|
if len(ruser.NotifyProps) == 0 {
|
||||||
|
t.Fatal("notify props should be sent")
|
||||||
|
}
|
||||||
|
|
||||||
Client.Logout()
|
Client.Logout()
|
||||||
_, resp = Client.GetUserByUsername(user.Username, "")
|
_, resp = Client.GetUserByUsername(user.Username, "")
|
||||||
CheckUnauthorizedStatus(t, resp)
|
CheckUnauthorizedStatus(t, resp)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user