You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user.go 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. import (
  6. "encoding/json"
  7. "time"
  8. )
  9. // User represents a user
  10. // swagger:model
  11. type User struct {
  12. // the user's id
  13. ID int64 `json:"id"`
  14. // the user's username
  15. UserName string `json:"login"`
  16. // the user's full name
  17. FullName string `json:"full_name"`
  18. // swagger:strfmt email
  19. Email string `json:"email"`
  20. // URL to the user's avatar
  21. AvatarURL string `json:"avatar_url"`
  22. // User locale
  23. Language string `json:"language"`
  24. // Is the user an administrator
  25. IsAdmin bool `json:"is_admin"`
  26. // swagger:strfmt date-time
  27. LastLogin time.Time `json:"last_login,omitempty"`
  28. // swagger:strfmt date-time
  29. Created time.Time `json:"created,omitempty"`
  30. }
  31. // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility
  32. func (u User) MarshalJSON() ([]byte, error) {
  33. // Re-declaring User to avoid recursion
  34. type shadow User
  35. return json.Marshal(struct {
  36. shadow
  37. CompatUserName string `json:"username"`
  38. }{shadow(u), u.UserName})
  39. }