code.gitea.io/gitea@v1.22.3/modules/structs/user.go (about) 1 // Copyright 2014 The Gogs Authors. All rights reserved. 2 // Copyright 2023 The Gitea Authors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 5 package structs 6 7 import ( 8 "time" 9 10 "code.gitea.io/gitea/modules/json" 11 ) 12 13 // User represents a user 14 // swagger:model 15 type User struct { 16 // the user's id 17 ID int64 `json:"id"` 18 // the user's username 19 UserName string `json:"login"` 20 // the user's authentication sign-in name. 21 // default: empty 22 LoginName string `json:"login_name"` 23 // The ID of the user's Authentication Source 24 SourceID int64 `json:"source_id"` 25 // the user's full name 26 FullName string `json:"full_name"` 27 // swagger:strfmt email 28 Email string `json:"email"` 29 // URL to the user's avatar 30 AvatarURL string `json:"avatar_url"` 31 // URL to the user's gitea page 32 HTMLURL string `json:"html_url"` 33 // User locale 34 Language string `json:"language"` 35 // Is the user an administrator 36 IsAdmin bool `json:"is_admin"` 37 // swagger:strfmt date-time 38 LastLogin time.Time `json:"last_login,omitempty"` 39 // swagger:strfmt date-time 40 Created time.Time `json:"created,omitempty"` 41 // Is user restricted 42 Restricted bool `json:"restricted"` 43 // Is user active 44 IsActive bool `json:"active"` 45 // Is user login prohibited 46 ProhibitLogin bool `json:"prohibit_login"` 47 // the user's location 48 Location string `json:"location"` 49 // the user's website 50 Website string `json:"website"` 51 // the user's description 52 Description string `json:"description"` 53 // User visibility level option: public, limited, private 54 Visibility string `json:"visibility"` 55 56 // user counts 57 Followers int `json:"followers_count"` 58 Following int `json:"following_count"` 59 StarredRepos int `json:"starred_repos_count"` 60 } 61 62 // MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility 63 func (u User) MarshalJSON() ([]byte, error) { 64 // Re-declaring User to avoid recursion 65 type shadow User 66 return json.Marshal(struct { 67 shadow 68 CompatUserName string `json:"username"` 69 }{shadow(u), u.UserName}) 70 } 71 72 // UserSettings represents user settings 73 // swagger:model 74 type UserSettings struct { 75 FullName string `json:"full_name"` 76 Website string `json:"website"` 77 Description string `json:"description"` 78 Location string `json:"location"` 79 Language string `json:"language"` 80 Theme string `json:"theme"` 81 DiffViewStyle string `json:"diff_view_style"` 82 // Privacy 83 HideEmail bool `json:"hide_email"` 84 HideActivity bool `json:"hide_activity"` 85 } 86 87 // UserSettingsOptions represents options to change user settings 88 // swagger:model 89 type UserSettingsOptions struct { 90 FullName *string `json:"full_name" binding:"MaxSize(100)"` 91 Website *string `json:"website" binding:"OmitEmpty;ValidUrl;MaxSize(255)"` 92 Description *string `json:"description" binding:"MaxSize(255)"` 93 Location *string `json:"location" binding:"MaxSize(50)"` 94 Language *string `json:"language"` 95 Theme *string `json:"theme"` 96 DiffViewStyle *string `json:"diff_view_style"` 97 // Privacy 98 HideEmail *bool `json:"hide_email"` 99 HideActivity *bool `json:"hide_activity"` 100 } 101 102 // RenameUserOption options when renaming a user 103 type RenameUserOption struct { 104 // New username for this user. This name cannot be in use yet by any other user. 105 // 106 // required: true 107 // unique: true 108 NewName string `json:"new_username" binding:"Required"` 109 } 110 111 // UpdateUserAvatarUserOption options when updating the user avatar 112 type UpdateUserAvatarOption struct { 113 // image must be base64 encoded 114 Image string `json:"image" binding:"Required"` 115 } 116 117 // Badge represents a user badge 118 // swagger:model 119 type Badge struct { 120 ID int64 `json:"id"` 121 Slug string `json:"slug"` 122 Description string `json:"description"` 123 ImageURL string `json:"image_url"` 124 } 125 126 // UserBadge represents a user badge 127 // swagger:model 128 type UserBadge struct { 129 ID int64 `json:"id"` 130 BadgeID int64 `json:"badge_id"` 131 UserID int64 `json:"user_id"` 132 } 133 134 // UserBadgeOption options for link between users and badges 135 type UserBadgeOption struct { 136 // example: ["badge1","badge2"] 137 BadgeSlugs []string `json:"badge_slugs" binding:"Required"` 138 }