// signed shall only be set if requester is logged in. authed shall only be set if user is site admin or user himself
func toUser(user *models.User, signed, authed bool) *api.User {
result := &api.User{
- ID: user.ID,
- UserName: user.Name,
- FullName: markup.Sanitize(user.FullName),
- Email: user.GetEmail(),
- AvatarURL: user.AvatarLink(),
- Created: user.CreatedUnix.AsTime(),
- Restricted: user.IsRestricted,
+ ID: user.ID,
+ UserName: user.Name,
+ FullName: markup.Sanitize(user.FullName),
+ Email: user.GetEmail(),
+ AvatarURL: user.AvatarLink(),
+ Created: user.CreatedUnix.AsTime(),
+ Restricted: user.IsRestricted,
+ Location: user.Location,
+ Website: user.Website,
+ Description: user.Description,
}
// hide primary email if API caller is anonymous or user keep email private
if signed && (!user.KeepEmailPrivate || authed) {
Created time.Time `json:"created,omitempty"`
// Is user restricted
Restricted bool `json:"restricted"`
+ // the user's location
+ Location string `json:"location"`
+ // the user's website
+ Website string `json:"website"`
+ // the user's biography
+ Description string `json:"bio"`
}
// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
"type": "string",
"x-go-name": "AvatarURL"
},
+ "bio": {
+ "description": "the user's biography",
+ "type": "string",
+ "x-go-name": "Description"
+ },
"created": {
"type": "string",
"format": "date-time",
"format": "date-time",
"x-go-name": "LastLogin"
},
+ "location": {
+ "description": "the user's location",
+ "type": "string",
+ "x-go-name": "Location"
+ },
"login": {
"description": "the user's username",
"type": "string",
"description": "Is user restricted",
"type": "boolean",
"x-go-name": "Restricted"
+ },
+ "website": {
+ "description": "the user's website",
+ "type": "string",
+ "x-go-name": "Website"
}
},
"x-go-package": "code.gitea.io/gitea/modules/structs"