File tree 1 file changed +7
-7
lines changed
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 {
256
256
}
257
257
258
258
// 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
259
260
func ToUser (user * models.User , signed , authed bool ) * api.User {
260
261
result := & api.User {
261
262
UserName : user .Name ,
262
263
AvatarURL : user .AvatarLink (),
263
264
FullName : markup .Sanitize (user .FullName ),
264
265
Created : user .CreatedUnix .AsTime (),
265
266
}
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 ) {
273
269
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
274
274
result .IsAdmin = user .IsAdmin
275
275
result .LastLogin = user .LastLoginUnix .AsTime ()
276
276
}
You can’t perform that action at this time.
0 commit comments