Returned User TermsOfService Data in Certain GetUser APIs To Be Used on Webapp for Decicion Making (#10478)
* Used user TOS data embedded in user object itself * #MI-372 Added user TOS data in getUserByUsername API and updated tests * #MI-372 returned user TOS data only for admin or self * #MI-372 fixed tests * #MI-372 added user ID checks in a missing place
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
f17de7929b
Коммит
f84be43937
26
api4/user.go
26
api4/user.go
@@ -119,6 +119,19 @@ func getUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.IsSystemAdmin() || c.App.Session.UserId == user.Id {
|
||||
userTermsOfService, err := c.App.GetUserTermsOfService(user.Id)
|
||||
if err != nil && err.StatusCode != http.StatusNotFound {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if userTermsOfService != nil {
|
||||
user.TermsOfServiceId = userTermsOfService.TermsOfServiceId
|
||||
user.TermsOfServiceCreateAt = userTermsOfService.CreateAt
|
||||
}
|
||||
}
|
||||
|
||||
etag := user.Etag(*c.App.Config().PrivacySettings.ShowFullName, *c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
|
||||
if c.HandleEtag(etag, "Get User", w, r) {
|
||||
@@ -149,6 +162,19 @@ func getUserByUsername(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if c.IsSystemAdmin() || c.App.Session.UserId == user.Id {
|
||||
userTermsOfService, err := c.App.GetUserTermsOfService(user.Id)
|
||||
if err != nil && err.StatusCode != http.StatusNotFound {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if userTermsOfService != nil {
|
||||
user.TermsOfServiceId = userTermsOfService.TermsOfServiceId
|
||||
user.TermsOfServiceCreateAt = userTermsOfService.CreateAt
|
||||
}
|
||||
}
|
||||
|
||||
etag := user.Etag(*c.App.Config().PrivacySettings.ShowFullName, *c.App.Config().PrivacySettings.ShowEmailAddress)
|
||||
|
||||
if c.HandleEtag(etag, "Get User", w, r) {
|
||||
|
||||
Ссылка в новой задаче
Block a user