File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -256,21 +256,21 @@ func ToTeam(team *models.Team) *api.Team {
256256}
257257
258258// ToUser convert models.User to api.User
259+ // signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
259260func ToUser (user * models.User , signed , authed bool ) * api.User {
260261 result := & api.User {
261262 UserName : user .Name ,
262263 AvatarURL : user .AvatarLink (),
263264 FullName : markup .Sanitize (user .FullName ),
264265 Created : user .CreatedUnix .AsTime (),
265266 }
266- // hide primary email if API caller isn't user itself or an admin
267- if ! signed {
268- result .Email = ""
269- } else if user .KeepEmailPrivate && ! authed {
270- result .Email = user .GetEmail ()
271- } else { // only user himself and admin could visit these information
272- result .ID = user .ID
267+ // hide primary email if API caller is anonymous or user keep email private
268+ if signed && (! user .KeepEmailPrivate || authed ) {
273269 result .Email = user .Email
270+ }
271+ // only site admin will get these information and possibly user himself
272+ if authed {
273+ result .ID = user .ID
274274 result .IsAdmin = user .IsAdmin
275275 result .LastLogin = user .LastLoginUnix .AsTime ()
276276 }
You can’t perform that action at this time.
0 commit comments