Documentation
¶
Index ¶
- Constants
- Variables
- func ActivateEmail(ctx context.Context, email *EmailAddress) error
- func ActivateUserEmail(ctx context.Context, userID int64, email string, activate bool) (err error)
- func AddUserBadge(ctx context.Context, u *User, badge *Badge) error
- func AddUserBadges(ctx context.Context, u *User, badges []*Badge) error
- func AddUserOpenID(ctx context.Context, openid *UserOpenID) error
- func AdminCreateUser(ctx context.Context, u *User, meta *Meta, ...) (err error)
- func BuildCanSeeUserCondition(actor *User) builder.Cond
- func ChangeInactivePrimaryEmail(ctx context.Context, uid int64, oldEmailAddr, newEmailAddr string) error
- func CountPinnedRepos(ctx context.Context, userID int64) (int64, error)
- func CountUsers(ctx context.Context, opts *CountUserFilter) int64
- func CountWrongUserType(ctx context.Context) (int64, error)
- func CreateBadge(ctx context.Context, badge *Badge) error
- func CreateUser(ctx context.Context, u *User, meta *Meta, ...) (err error)
- func DeleteBadge(ctx context.Context, badge *Badge) error
- func DeletePinnedReposByRepoID(ctx context.Context, repoID int64) error
- func DeleteUserOpenID(ctx context.Context, openid *UserOpenID) (err error)
- func DeleteUserRedirect(ctx context.Context, userName string) error
- func DeleteUserSetting(ctx context.Context, userID int64, key string) error
- func DisabledFeaturesWithLoginType(user *User) *container.Set[string]
- func EnsureLinkExternalToUser(ctx context.Context, external *ExternalLoginUser) error
- func ExistsWithAvatarAtStoragePath(ctx context.Context, storagePath string) (bool, error)
- func FixWrongUserType(ctx context.Context) (int64, error)
- func FollowUser(ctx context.Context, user, follow *User) (err error)
- func GenerateRandomAvatar(ctx context.Context, u *User) error
- func GenerateUserTimeLimitCode(opts *TimeLimitCodeOptions, u *User) string
- func GetActivatedEmailAddresses(ctx context.Context, uid int64) ([]string, error)
- func GetExternalLogin(ctx context.Context, externalLoginUser *ExternalLoginUser) (bool, error)
- func GetOrderByName() string
- func GetSetting(ctx context.Context, uid int64, key string) (string, error)
- func GetSettings(ctx context.Context, uid int64, keys []string) (map[string]*Setting, error)
- func GetUser(ctx context.Context, user *User) (bool, error)
- func GetUserAllSettings(ctx context.Context, uid int64) (map[string]*Setting, error)
- func GetUserEmailsByNames(ctx context.Context, names []string) []string
- func GetUserIDByExternalUserID(ctx context.Context, provider, userID string) (int64, error)
- func GetUserIDsByNames(ctx context.Context, names []string, ignoreNonExistent bool) ([]int64, error)
- func GetUserNameByID(ctx context.Context, id int64) (string, error)
- func GetUserOrOrgIDByName(ctx context.Context, name string) (int64, error)
- func GetUserSalt() (string, error)
- func GetUserSetting(ctx context.Context, userID int64, key string, def ...string) (string, error)
- func GetUsersMapByIDs(ctx context.Context, userIDs []int64) (map[int64]*User, error)
- func HasUsers(ctx context.Context) (ret struct{ ... }, err error)
- func IncrUserRepoNum(ctx context.Context, userID int64) error
- func IsEmailActive(ctx context.Context, email string, excludeEmailID int64) (bool, error)
- func IsEmailDomainAllowed(email string) bool
- func IsEmailUsed(ctx context.Context, email string) (bool, error)
- func IsErrDeleteLastAdminUser(err error) bool
- func IsErrEmailAddressNotExist(err error) bool
- func IsErrEmailAlreadyUsed(err error) bool
- func IsErrEmailCharIsNotSupported(err error) bool
- func IsErrEmailInvalid(err error) bool
- func IsErrExternalLoginUserAlreadyExist(err error) bool
- func IsErrExternalLoginUserNotExist(err error) bool
- func IsErrOpenIDAlreadyUsed(err error) bool
- func IsErrPinnedRepoLimit(err error) bool
- func IsErrPrimaryEmailCannotDelete(err error) bool
- func IsErrUserAlreadyExist(err error) bool
- func IsErrUserInactive(err error) bool
- func IsErrUserIsNotLocal(err error) bool
- func IsErrUserNotExist(err error) bool
- func IsErrUserProhibitLogin(err error) bool
- func IsErrUserRedirectNotExist(err error) bool
- func IsErrUserSettingIsNotExist(err error) bool
- func IsFeatureDisabledWithLoginType(user *User, features ...string) bool
- func IsFollowing(ctx context.Context, userID, followID int64) bool
- func IsGhostUserName(name string) bool
- func IsGiteaActionsUserName(name string) bool
- func IsLastAdminUser(ctx context.Context, user *User) bool
- func IsRepoPinnedByUser(ctx context.Context, userID, repoID int64) (bool, error)
- func IsUsableUsername(name string) error
- func IsUserBlockedBy(ctx context.Context, blockee *User, blockerIDs ...int64) bool
- func IsUserExist(ctx context.Context, uid int64, name string) (bool, error)
- func IsUserVisibleToViewer(ctx context.Context, u, viewer *User) bool
- func IterateExternalLogin(ctx context.Context, opts FindExternalUserOptions, ...) error
- func LinkExternalToUser(ctx context.Context, user *User, externalLoginUser *ExternalLoginUser) error
- func LookupUserRedirect(ctx context.Context, userName string) (int64, error)
- func MakeActiveEmailPrimary(ctx context.Context, emailID int64) error
- func MakeInactiveEmailPrimary(ctx context.Context, emailID int64) error
- func NewUserRedirect(ctx context.Context, ID int64, oldUserName, newUserName string) error
- func NormalizeUserName(s string) (string, error)
- func PinRepoToUser(ctx context.Context, userID, repoID int64) error
- func RemoveAccountLink(ctx context.Context, user *User, loginSourceID int64) (int64, error)
- func RemoveAllAccountLinks(ctx context.Context, user *User) error
- func RemoveAllUserBadges(ctx context.Context, u *User) error
- func RemoveUserBadge(ctx context.Context, u *User, badge *Badge) error
- func RemoveUserBadges(ctx context.Context, u *User, badges []*Badge) error
- func SetMustChangePassword(ctx context.Context, all, mustChangePassword bool, include, exclude []string) (int64, error)
- func SetUserSetting(ctx context.Context, userID int64, key, value string) error
- func ToggleUserOpenIDVisibility(ctx context.Context, id int64) (err error)
- func UnfollowUser(ctx context.Context, userID, followID int64) (err error)
- func UnpinRepoFromUser(ctx context.Context, userID, repoID int64) error
- func UpdateBadge(ctx context.Context, badge *Badge) error
- func UpdateBlockingNote(ctx context.Context, id int64, note string) error
- func UpdateEmailAddress(ctx context.Context, email *EmailAddress) error
- func UpdateExternalUserByExternalID(ctx context.Context, external *ExternalLoginUser) error
- func UpdatePinnedRepoOrder(ctx context.Context, userID int64, repoIDs []int64) error
- func UpdateUserCols(ctx context.Context, u *User, cols ...string) error
- func UpdateUserColsNoAutoTime(ctx context.Context, u *User, cols ...string) error
- func UserPath(userName string) string
- func ValidateEmail(email string) error
- func ValidateEmailForAdmin(email string) error
- func ValidateUser(u *User, cols ...string) error
- type Badge
- type Blocking
- type BlockingList
- type CountUserFilter
- type CreateUserOverwriteOptions
- type EmailAddress
- func GetEmailAddressByEmail(ctx context.Context, email string) (*EmailAddress, error)
- func GetEmailAddressByID(ctx context.Context, uid, id int64) (*EmailAddress, error)
- func GetEmailAddressOfUser(ctx context.Context, email string, uid int64) (*EmailAddress, error)
- func GetEmailAddresses(ctx context.Context, uid int64) ([]*EmailAddress, error)
- func GetPrimaryEmailAddressOfUser(ctx context.Context, uid int64) (*EmailAddress, error)
- func InsertEmailAddress(ctx context.Context, email *EmailAddress) (*EmailAddress, error)
- func VerifyActiveEmailCode(ctx context.Context, code, email string) *EmailAddress
- type EmailUserMap
- type ErrDeleteLastAdminUser
- type ErrEmailAddressNotExist
- type ErrEmailAlreadyUsed
- type ErrEmailCharIsNotSupported
- type ErrEmailInvalid
- type ErrExternalLoginUserAlreadyExist
- type ErrExternalLoginUserNotExist
- type ErrOpenIDAlreadyUsed
- type ErrPinnedRepoLimit
- type ErrPrimaryEmailCannotDelete
- type ErrUserAlreadyExist
- type ErrUserInactive
- type ErrUserIsNotLocal
- type ErrUserNotExist
- type ErrUserProhibitLogin
- type ErrUserRedirectNotExist
- type ErrUserSettingIsNotExist
- type ExternalLoginUser
- type ExternalUserMigrated
- type ExternalUserRemappable
- type FindBlockingOptions
- type FindExternalUserOptions
- type Follow
- type Meta
- type PinnedRepo
- type Redirect
- type SearchEmailOptions
- type SearchEmailOrderBy
- type SearchEmailResult
- type SearchOrganizationsOptions
- type SearchUserOptions
- type Setting
- type TimeLimitCodeOptions
- type TimeLimitCodePurpose
- type User
- func GetAdminUser(ctx context.Context) (*User, error)
- func GetAllUsers(ctx context.Context) ([]*User, error)
- func GetInactiveUsers(ctx context.Context, olderThan time.Duration) ([]*User, error)
- func GetMailableUsersByIDs(ctx context.Context, ids []int64, isMention bool) ([]*User, error)
- func GetPossibleUserByID(ctx context.Context, id int64) (*User, error)
- func GetPossibleUserByIDs(ctx context.Context, ids []int64) ([]*User, error)
- func GetPossibleUserFromMap(userID int64, usererMaps map[int64]*User) *User
- func GetSystemUserByName(name string) *User
- func GetUserByEmail(ctx context.Context, email string) (*User, error)
- func GetUserByID(ctx context.Context, id int64) (*User, error)
- func GetUserByIDs(ctx context.Context, ids []int64) ([]*User, error)
- func GetUserByName(ctx context.Context, name string) (*User, error)
- func GetUserByOpenID(ctx context.Context, uri string) (*User, error)
- func GetUserFollowers(ctx context.Context, u, viewer *User, listOptions db.ListOptions) ([]*User, int64, error)
- func GetUserFollowing(ctx context.Context, u, viewer *User, listOptions db.ListOptions) ([]*User, int64, error)
- func GetUserOrOrgByName(ctx context.Context, name string) (*User, error)
- func GetUsersBySource(ctx context.Context, s *auth.Source) ([]*User, error)
- func GetVerifyUser(ctx context.Context, code string) (user *User)
- func NewActionsUser() *User
- func NewGhostUser() *User
- func SearchUsers(ctx context.Context, opts SearchUserOptions) (users []*User, _ int64, _ error)
- func ValidateCommitWithEmail(ctx context.Context, c *git.Commit) *User
- func VerifyUserTimeLimitCode(ctx context.Context, opts *TimeLimitCodeOptions, code string) (user *User)
- func (u *User) AfterLoad()
- func (u *User) AvatarLink(ctx context.Context) string
- func (u *User) AvatarLinkWithSize(ctx context.Context, size int) string
- func (u *User) BeforeUpdate()
- func (u *User) CanCreateOrganization() bool
- func (u *User) CanCreateRepoIn(owner *User) bool
- func (u *User) CanEditGitHook() bool
- func (u *User) CanForkRepoIn(owner *User) bool
- func (u *User) CanImportLocal() bool
- func (u *User) CustomAvatarRelativePath() string
- func (u *User) DashboardLink() string
- func (u *User) DisplayName() string
- func (u *User) EmailTo() string
- func (u *User) GetCompleteName() string
- func (u *User) GetDisplayName() string
- func (u *User) GetEmail() string
- func (u *User) GetPlaceholderEmail() string
- func (u *User) GitName() string
- func (u *User) HTMLURL(ctx context.Context) string
- func (u *User) HomeLink() string
- func (u *User) IsGhost() bool
- func (u *User) IsGiteaActions() bool
- func (u *User) IsIndividual() bool
- func (u *User) IsLocal() bool
- func (u *User) IsMailable() bool
- func (u *User) IsOAuth2() bool
- func (u *User) IsOrganization() bool
- func (u *User) IsPasswordSet() bool
- func (u *User) IsTokenAccessAllowed() bool
- func (u *User) IsTypeBot() bool
- func (u *User) IsUploadAvatarChanged(data []byte) bool
- func (u *User) LogString() string
- func (u *User) MaxCreationLimit() int
- func (u *User) NewGitSig() *git.Signature
- func (u *User) OrganisationLink() string
- func (u *User) SetLastLogin()
- func (u *User) SetPassword(passwd string) (err error)
- func (u *User) ShortName(length int) string
- func (u *User) ValidatePassword(passwd string) bool
- type UserBadge
- type UserCommit
- type UserList
- type UserOpenID
- type UserType
Constants ¶
const ( // SettingsKeyHiddenCommentTypes is the setting key for hidden comment types SettingsKeyHiddenCommentTypes = "issue.hidden_comment_types" // SettingsKeyDiffWhitespaceBehavior is the setting key for whitespace behavior of diff SettingsKeyDiffWhitespaceBehavior = "diff.whitespace_behaviour" // SettingsKeyShowOutdatedComments is the setting key whether or not to show outdated comments in PRs SettingsKeyShowOutdatedComments = "comment_code.show_outdated" // UserActivityPubPrivPem is user's private key UserActivityPubPrivPem = "activitypub.priv_pem" // UserActivityPubPubPem is user's public key UserActivityPubPubPem = "activitypub.pub_pem" // SignupIP is the IP address that the user signed up with SignupIP = "signup.ip" // SignupUserAgent is the user agent that the user signed up with SignupUserAgent = "signup.user_agent" SettingsKeyCodeViewShowFileTree = "code_view.show_file_tree" SettingsKeyEmailNotificationGiteaActions = "email_notification.gitea_actions" SettingEmailNotificationGiteaActionsAll = "all" SettingEmailNotificationGiteaActionsFailureOnly = "failure-only" // Default for actions email preference SettingEmailNotificationGiteaActionsDisabled = "disabled" )
const ( // EmailNotificationsEnabled indicates that the user would like to receive all email notifications except your own EmailNotificationsEnabled = "enabled" // EmailNotificationsOnMention indicates that the user would like to be notified via email when mentioned. EmailNotificationsOnMention = "onmention" // EmailNotificationsDisabled indicates that the user would not like to be notified via email. EmailNotificationsDisabled = "disabled" // EmailNotificationsAndYourOwn indicates that the user would like to receive all email notifications and your own EmailNotificationsAndYourOwn = "andyourown" )
const ( GhostUserID int64 = -1 GhostUserName = "Ghost" )
const ( ActionsUserID int64 = -2 ActionsUserName = "gitea-actions" ActionsUserEmail = "teabot@gitea.io" )
const MaxPinnedRepos = 6
MaxPinnedRepos is the maximum number of repos a user can pin
const SaltByteLength = 16
SaltByteLength as of the beginning of 2022, it is recommended to use at least 64 bits of salt, but NIST is already recommending to use to 128 bits. (16 bytes = 16 * 8 = 128 bits)
Variables ¶
var ( ErrBlockOrganization = util.NewInvalidArgumentErrorf("cannot block an organization") ErrCanNotBlock = util.NewInvalidArgumentErrorf("cannot block the user") ErrCanNotUnblock = util.NewInvalidArgumentErrorf("cannot unblock the user") ErrBlockedUser = util.NewPermissionDeniedErrorf("user is blocked") )
var AdminUserOrderByMap = map[string]map[string]db.SearchOrderBy{ "asc": { "name": db.SearchOrderByAlphabetically, "created": db.SearchOrderByOldest, "updated": db.SearchOrderByLeastUpdated, "id": db.SearchOrderByID, }, "desc": { "name": db.SearchOrderByAlphabeticallyReverse, "created": db.SearchOrderByNewest, "updated": db.SearchOrderByRecentUpdated, "id": db.SearchOrderByIDReverse, }, }
AdminUserOrderByMap represents all possible admin user search orders This should only be used for admin API endpoints as we should not expose "updated" ordering which could expose recent user activity including logins.
Functions ¶
func ActivateEmail ¶
func ActivateEmail(ctx context.Context, email *EmailAddress) error
ActivateEmail activates the email address to given user.
func ActivateUserEmail ¶
ActivateUserEmail will change the activated state of an email address, either primary or secondary (all in the email_address table)
func AddUserBadge ¶
AddUserBadge adds a badge to a user.
func AddUserBadges ¶
AddUserBadges adds badges to a user.
func AddUserOpenID ¶
func AddUserOpenID(ctx context.Context, openid *UserOpenID) error
AddUserOpenID adds an pre-verified/normalized OpenID URI to given user. NOTE: make sure openid.URI is normalized already
func AdminCreateUser ¶
func AdminCreateUser(ctx context.Context, u *User, meta *Meta, overwriteDefault ...*CreateUserOverwriteOptions) (err error)
AdminCreateUser is used by admins to manually create users
func BuildCanSeeUserCondition ¶
BuildCanSeeUserCondition creates a condition which can be used to restrict results to users/orgs the actor can see
func ChangeInactivePrimaryEmail ¶
func ChangeInactivePrimaryEmail(ctx context.Context, uid int64, oldEmailAddr, newEmailAddr string) error
ChangeInactivePrimaryEmail replaces the inactive primary email of a given user
func CountPinnedRepos ¶
CountPinnedRepos returns the count of pinned repos for a user
func CountUsers ¶
func CountUsers(ctx context.Context, opts *CountUserFilter) int64
CountUsers returns number of users.
func CountWrongUserType ¶
CountWrongUserType count OrgUser who have wrong type
func CreateBadge ¶
CreateBadge creates a new badge.
func CreateUser ¶
func CreateUser(ctx context.Context, u *User, meta *Meta, overwriteDefault ...*CreateUserOverwriteOptions) (err error)
CreateUser creates record of a new user.
func DeleteBadge ¶
DeleteBadge deletes a badge.
func DeletePinnedReposByRepoID ¶
DeletePinnedReposByRepoID deletes all pins for a repo (when repo is deleted)
func DeleteUserOpenID ¶
func DeleteUserOpenID(ctx context.Context, openid *UserOpenID) (err error)
DeleteUserOpenID deletes an openid address of given user.
func DeleteUserRedirect ¶
DeleteUserRedirect delete any redirect from the specified user name to anything else
func DeleteUserSetting ¶
DeleteUserSetting deletes a specific setting for a user
func DisabledFeaturesWithLoginType ¶
DisabledFeaturesWithLoginType returns the set of user features disabled, taking into account the login type of the user if applicable
func EnsureLinkExternalToUser ¶
func EnsureLinkExternalToUser(ctx context.Context, external *ExternalLoginUser) error
EnsureLinkExternalToUser link the external user to the user
func ExistsWithAvatarAtStoragePath ¶
ExistsWithAvatarAtStoragePath returns true if there is a user with this Avatar
func FixWrongUserType ¶
FixWrongUserType fix OrgUser who have wrong type
func FollowUser ¶
FollowUser marks someone be another's follower.
func GenerateRandomAvatar ¶
GenerateRandomAvatar generates a random avatar for user.
func GenerateUserTimeLimitCode ¶
func GenerateUserTimeLimitCode(opts *TimeLimitCodeOptions, u *User) string
GenerateUserTimeLimitCode generates a time-limit code based on user information and given e-mail. TODO: need to use cache or db to store it to make sure a code can only be consumed once
func GetActivatedEmailAddresses ¶
func GetExternalLogin ¶
func GetExternalLogin(ctx context.Context, externalLoginUser *ExternalLoginUser) (bool, error)
GetExternalLogin checks if a externalID in loginSourceID scope already exists
func GetSetting ¶
GetSetting returns the setting value via the key
func GetSettings ¶
GetSettings returns specific settings from user
func GetUser ¶
GetUser checks if a user already exists
func GetUserAllSettings ¶
GetUserAllSettings returns all settings from user
func GetUserEmailsByNames ¶
GetUserEmailsByNames returns a list of e-mails corresponds to names of users that have their email notifications set to enabled or onmention.
func GetUserIDByExternalUserID ¶
GetUserIDByExternalUserID get user id according to provider and userID
func GetUserIDsByNames ¶
func GetUserIDsByNames(ctx context.Context, names []string, ignoreNonExistent bool) ([]int64, error)
GetUserIDsByNames returns a slice of ids corresponds to names.
func GetUserNameByID ¶
GetUserNameByID returns username for the id
func GetUserOrOrgIDByName ¶
GetUserOrOrgIDByName returns the id for a user or an org by name
func GetUserSetting ¶
GetUserSetting gets a specific setting for a user
func GetUsersMapByIDs ¶
func HasUsers ¶
HasUsers checks whether there are any users in the database, or only one user exists.
func IsEmailActive ¶
IsEmailActive check if email is activated with a different emailID
func IsEmailUsed ¶
IsEmailUsed returns true if the email has been used.
func IsErrDeleteLastAdminUser ¶
IsErrDeleteLastAdminUser checks if an error is a ErrDeleteLastAdminUser.
func IsErrEmailAddressNotExist ¶
IsErrEmailAddressNotExist checks if an error is an ErrEmailAddressNotExist
func IsErrEmailAlreadyUsed ¶
IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
func IsErrEmailCharIsNotSupported ¶
IsErrEmailCharIsNotSupported checks if an error is an ErrEmailCharIsNotSupported
func IsErrEmailInvalid ¶
IsErrEmailInvalid checks if an error is an ErrEmailInvalid
func IsErrExternalLoginUserAlreadyExist ¶
IsErrExternalLoginUserAlreadyExist checks if an error is a ExternalLoginUserAlreadyExist.
func IsErrExternalLoginUserNotExist ¶
IsErrExternalLoginUserNotExist checks if an error is a ExternalLoginUserNotExist.
func IsErrOpenIDAlreadyUsed ¶
IsErrOpenIDAlreadyUsed checks if an error is a ErrOpenIDAlreadyUsed.
func IsErrPinnedRepoLimit ¶
IsErrPinnedRepoLimit checks if error is ErrPinnedRepoLimit
func IsErrPrimaryEmailCannotDelete ¶
IsErrPrimaryEmailCannotDelete checks if an error is an ErrPrimaryEmailCannotDelete
func IsErrUserAlreadyExist ¶
IsErrUserAlreadyExist checks if an error is a ErrUserAlreadyExists.
func IsErrUserInactive ¶
IsErrUserInactive checks if an error is a ErrUserInactive
func IsErrUserNotExist ¶
IsErrUserNotExist checks if an error is a ErrUserNotExist.
func IsErrUserProhibitLogin ¶
IsErrUserProhibitLogin checks if an error is a ErrUserProhibitLogin
func IsErrUserRedirectNotExist ¶
IsErrUserRedirectNotExist check if an error is an ErrUserRedirectNotExist.
func IsErrUserSettingIsNotExist ¶
IsErrUserSettingIsNotExist return true if err is ErrSettingIsNotExist
func IsFeatureDisabledWithLoginType ¶
IsFeatureDisabledWithLoginType checks if a user features are disabled, taking into account the login type of the user if applicable
func IsFollowing ¶
IsFollowing returns true if user is following followID.
func IsLastAdminUser ¶
IsLastAdminUser check whether user is the last admin
func IsRepoPinnedByUser ¶
IsRepoPinnedByUser checks if a repo is pinned by a user
func IsUsableUsername ¶
IsUsableUsername returns an error when a username is reserved
func IsUserBlockedBy ¶
func IsUserExist ¶
IsUserExist checks if given username exist, the username should be non-cased unique. If uid is presented, then check will rule out that one, it is used when update a username in settings page.
func IsUserVisibleToViewer ¶
IsUserVisibleToViewer check if viewer is able to see user profile
func IterateExternalLogin ¶
func IterateExternalLogin(ctx context.Context, opts FindExternalUserOptions, f func(ctx context.Context, u *ExternalLoginUser) error) error
func LinkExternalToUser ¶
func LinkExternalToUser(ctx context.Context, user *User, externalLoginUser *ExternalLoginUser) error
LinkExternalToUser link the external user to the user
func LookupUserRedirect ¶
LookupUserRedirect look up userID if a user has a redirect name
func MakeInactiveEmailPrimary ¶
func NewUserRedirect ¶
NewUserRedirect create a new user redirect
func NormalizeUserName ¶
NormalizeUserName only takes the name part if it is an email address, transforms it diacritics to ASCII characters. It returns a string with the single-quotes removed, and any other non-supported username characters are replaced with a `-` character
func PinRepoToUser ¶
PinRepoToUser pins a repo to a user's profile
func RemoveAccountLink ¶
RemoveAccountLink will remove all external login sources for the given user
func RemoveAllAccountLinks ¶
RemoveAllAccountLinks will remove all external login sources for the given user
func RemoveAllUserBadges ¶
RemoveAllUserBadges removes all badges from a user.
func RemoveUserBadge ¶
RemoveUserBadge removes a badge from a user.
func RemoveUserBadges ¶
RemoveUserBadges removes badges from a user.
func SetMustChangePassword ¶
func SetUserSetting ¶
SetUserSetting updates a users' setting for a specific key
func ToggleUserOpenIDVisibility ¶
ToggleUserOpenIDVisibility toggles visibility of an openid address of given user.
func UnfollowUser ¶
UnfollowUser unmarks someone as another's follower.
func UnpinRepoFromUser ¶
UnpinRepoFromUser unpins a repo from a user's profile
func UpdateBadge ¶
UpdateBadge updates a badge based on its slug.
func UpdateEmailAddress ¶
func UpdateEmailAddress(ctx context.Context, email *EmailAddress) error
func UpdateExternalUserByExternalID ¶
func UpdateExternalUserByExternalID(ctx context.Context, external *ExternalLoginUser) error
UpdateExternalUserByExternalID updates an external user's information
func UpdatePinnedRepoOrder ¶
UpdatePinnedRepoOrder updates the display order of pinned repos
func UpdateUserCols ¶
UpdateUserCols update user according special columns
func UpdateUserColsNoAutoTime ¶
UpdateUserColsNoAutoTime update user according special columns
func UserPath ¶
UserPath returns the path absolute path of user repositories.
func ValidateEmail ¶
ValidateEmail check if email is a valid & allowed address
func ValidateEmailForAdmin ¶
ValidateEmailForAdmin check if email is a valid address when admins manually add or edit users
Types ¶
type Badge ¶
type Badge struct {
ID int64 `xorm:"pk autoincr"`
Slug string `xorm:"UNIQUE"`
Description string
ImageURL string
}
Badge represents a user badge
func GetBadge ¶
GetBadge returns a badge
type Blocking ¶
type Blocking struct {
ID int64 `xorm:"pk autoincr"`
BlockerID int64 `xorm:"UNIQUE(block)"`
Blocker *User `xorm:"-"`
BlockeeID int64 `xorm:"UNIQUE(block)"`
Blockee *User `xorm:"-"`
Note string
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
}
func FindBlockings ¶
func GetBlocking ¶
type BlockingList ¶
type BlockingList []*Blocking
func (BlockingList) LoadAttributes ¶
func (blocks BlockingList) LoadAttributes(ctx context.Context) error
type CountUserFilter ¶
type CountUserFilter struct {
LastLoginSince *int64
IsAdmin optional.Option[bool]
IsActive optional.Option[bool]
}
CountUserFilter represent optional filters for CountUsers
type CreateUserOverwriteOptions ¶
type CreateUserOverwriteOptions struct {
KeepEmailPrivate optional.Option[bool]
Visibility *structs.VisibleType
AllowCreateOrganization optional.Option[bool]
EmailNotificationsPreference *string
MaxRepoCreation *int
Theme *string
IsRestricted optional.Option[bool]
IsActive optional.Option[bool]
}
CreateUserOverwriteOptions are an optional options who overwrite system defaults on user creation
type EmailAddress ¶
type EmailAddress struct {
ID int64 `xorm:"pk autoincr"`
UID int64 `xorm:"INDEX NOT NULL"`
Email string `xorm:"UNIQUE NOT NULL"`
LowerEmail string `xorm:"UNIQUE NOT NULL"`
IsActivated bool
IsPrimary bool `xorm:"DEFAULT(false) NOT NULL"`
}
EmailAddress is the list of all email addresses of a user. It also contains the primary email address which is saved in user table.
func GetEmailAddressByEmail ¶
func GetEmailAddressByEmail(ctx context.Context, email string) (*EmailAddress, error)
func GetEmailAddressByID ¶
func GetEmailAddressByID(ctx context.Context, uid, id int64) (*EmailAddress, error)
GetEmailAddressByID gets a user's email address by ID
func GetEmailAddressOfUser ¶
func GetEmailAddresses ¶
func GetEmailAddresses(ctx context.Context, uid int64) ([]*EmailAddress, error)
GetEmailAddresses returns all email addresses belongs to given user.
func GetPrimaryEmailAddressOfUser ¶
func GetPrimaryEmailAddressOfUser(ctx context.Context, uid int64) (*EmailAddress, error)
func InsertEmailAddress ¶
func InsertEmailAddress(ctx context.Context, email *EmailAddress) (*EmailAddress, error)
func VerifyActiveEmailCode ¶
func VerifyActiveEmailCode(ctx context.Context, code, email string) *EmailAddress
VerifyActiveEmailCode verifies active email code when active account
func (*EmailAddress) BeforeInsert ¶
func (email *EmailAddress) BeforeInsert()
BeforeInsert will be invoked by XORM before inserting a record
type EmailUserMap ¶
type EmailUserMap struct {
// contains filtered or unexported fields
}
func GetUsersByEmails ¶
func GetUsersByEmails(ctx context.Context, emails []string) (*EmailUserMap, error)
func (*EmailUserMap) GetByEmail ¶
func (eum *EmailUserMap) GetByEmail(email string) *User
type ErrDeleteLastAdminUser ¶
type ErrDeleteLastAdminUser struct {
UID int64
}
ErrDeleteLastAdminUser represents a "DeleteLastAdminUser" kind of error.
func (ErrDeleteLastAdminUser) Error ¶
func (err ErrDeleteLastAdminUser) Error() string
type ErrEmailAddressNotExist ¶
type ErrEmailAddressNotExist struct {
Email string
}
ErrEmailAddressNotExist email address not exist
func (ErrEmailAddressNotExist) Error ¶
func (err ErrEmailAddressNotExist) Error() string
func (ErrEmailAddressNotExist) Unwrap ¶
func (err ErrEmailAddressNotExist) Unwrap() error
type ErrEmailAlreadyUsed ¶
type ErrEmailAlreadyUsed struct {
Email string
}
ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.
func (ErrEmailAlreadyUsed) Error ¶
func (err ErrEmailAlreadyUsed) Error() string
func (ErrEmailAlreadyUsed) Unwrap ¶
func (err ErrEmailAlreadyUsed) Unwrap() error
type ErrEmailCharIsNotSupported ¶
type ErrEmailCharIsNotSupported struct {
Email string
}
ErrEmailCharIsNotSupported e-mail address contains unsupported character
func (ErrEmailCharIsNotSupported) Error ¶
func (err ErrEmailCharIsNotSupported) Error() string
func (ErrEmailCharIsNotSupported) Unwrap ¶
func (err ErrEmailCharIsNotSupported) Unwrap() error
type ErrEmailInvalid ¶
type ErrEmailInvalid struct {
Email string
}
ErrEmailInvalid represents an error where the email address does not comply with RFC 5322 or has a leading '-' character
func (ErrEmailInvalid) Error ¶
func (err ErrEmailInvalid) Error() string
func (ErrEmailInvalid) Unwrap ¶
func (err ErrEmailInvalid) Unwrap() error
type ErrExternalLoginUserAlreadyExist ¶
ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
func (ErrExternalLoginUserAlreadyExist) Error ¶
func (err ErrExternalLoginUserAlreadyExist) Error() string
func (ErrExternalLoginUserAlreadyExist) Unwrap ¶
func (err ErrExternalLoginUserAlreadyExist) Unwrap() error
type ErrExternalLoginUserNotExist ¶
ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
func (ErrExternalLoginUserNotExist) Error ¶
func (err ErrExternalLoginUserNotExist) Error() string
func (ErrExternalLoginUserNotExist) Unwrap ¶
func (err ErrExternalLoginUserNotExist) Unwrap() error
type ErrOpenIDAlreadyUsed ¶
type ErrOpenIDAlreadyUsed struct {
OpenID string
}
ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.
func (ErrOpenIDAlreadyUsed) Error ¶
func (err ErrOpenIDAlreadyUsed) Error() string
func (ErrOpenIDAlreadyUsed) Unwrap ¶
func (err ErrOpenIDAlreadyUsed) Unwrap() error
type ErrPinnedRepoLimit ¶
ErrPinnedRepoLimit represents an error when user has reached pin limit
func (ErrPinnedRepoLimit) Error ¶
func (err ErrPinnedRepoLimit) Error() string
type ErrPrimaryEmailCannotDelete ¶
type ErrPrimaryEmailCannotDelete struct {
Email string
}
ErrPrimaryEmailCannotDelete primary email address cannot be deleted
func (ErrPrimaryEmailCannotDelete) Error ¶
func (err ErrPrimaryEmailCannotDelete) Error() string
func (ErrPrimaryEmailCannotDelete) Unwrap ¶
func (err ErrPrimaryEmailCannotDelete) Unwrap() error
type ErrUserAlreadyExist ¶
type ErrUserAlreadyExist struct {
Name string
}
ErrUserAlreadyExist represents a "user already exists" error.
func (ErrUserAlreadyExist) Error ¶
func (err ErrUserAlreadyExist) Error() string
func (ErrUserAlreadyExist) Unwrap ¶
func (err ErrUserAlreadyExist) Unwrap() error
Unwrap unwraps this error as a ErrExist error
type ErrUserInactive ¶
ErrUserInactive represents a "ErrUserInactive" kind of error.
func (ErrUserInactive) Error ¶
func (err ErrUserInactive) Error() string
func (ErrUserInactive) Unwrap ¶
func (err ErrUserInactive) Unwrap() error
Unwrap unwraps this error as a ErrPermission error
type ErrUserIsNotLocal ¶
ErrUserIsNotLocal represents a "ErrUserIsNotLocal" kind of error.
func (ErrUserIsNotLocal) Error ¶
func (err ErrUserIsNotLocal) Error() string
type ErrUserNotExist ¶
ErrUserNotExist represents a "UserNotExist" kind of error.
func (ErrUserNotExist) Error ¶
func (err ErrUserNotExist) Error() string
func (ErrUserNotExist) Unwrap ¶
func (err ErrUserNotExist) Unwrap() error
Unwrap unwraps this error as a ErrNotExist error
type ErrUserProhibitLogin ¶
ErrUserProhibitLogin represents a "ErrUserProhibitLogin" kind of error.
func (ErrUserProhibitLogin) Error ¶
func (err ErrUserProhibitLogin) Error() string
func (ErrUserProhibitLogin) Unwrap ¶
func (err ErrUserProhibitLogin) Unwrap() error
Unwrap unwraps this error as a ErrPermission error
type ErrUserRedirectNotExist ¶
type ErrUserRedirectNotExist struct {
Name string
}
ErrUserRedirectNotExist represents a "UserRedirectNotExist" kind of error.
func (ErrUserRedirectNotExist) Error ¶
func (err ErrUserRedirectNotExist) Error() string
func (ErrUserRedirectNotExist) Unwrap ¶
func (err ErrUserRedirectNotExist) Unwrap() error
type ErrUserSettingIsNotExist ¶
type ErrUserSettingIsNotExist struct {
Key string
}
ErrUserSettingIsNotExist represents an error that a setting is not exist with special key
func (ErrUserSettingIsNotExist) Error ¶
func (err ErrUserSettingIsNotExist) Error() string
Error implements error
func (ErrUserSettingIsNotExist) Unwrap ¶
func (err ErrUserSettingIsNotExist) Unwrap() error
type ExternalLoginUser ¶
type ExternalLoginUser struct {
ExternalID string `xorm:"pk NOT NULL"`
UserID int64 `xorm:"INDEX NOT NULL"`
LoginSourceID int64 `xorm:"pk NOT NULL"`
RawData map[string]any `xorm:"TEXT JSON"`
Provider string `xorm:"index VARCHAR(25)"`
Email string
Name string
FirstName string
LastName string
NickName string
Description string
AvatarURL string `xorm:"TEXT"`
Location string
AccessToken string `xorm:"TEXT"`
AccessTokenSecret string `xorm:"TEXT"`
RefreshToken string `xorm:"TEXT"`
ExpiresAt time.Time
}
ExternalLoginUser makes the connecting between some existing user and additional external login sources
type ExternalUserMigrated ¶
type ExternalUserRemappable ¶
type ExternalUserRemappable interface {
GetUserID() int64
RemapExternalUser(externalName string, externalID, userID int64) error
ExternalUserMigrated
}
type FindBlockingOptions ¶
type FindBlockingOptions struct {
db.ListOptions
BlockerID int64
BlockeeID int64
}
func (*FindBlockingOptions) ToConds ¶
func (opts *FindBlockingOptions) ToConds() builder.Cond
type FindExternalUserOptions ¶
type FindExternalUserOptions struct {
db.ListOptions
Provider string
UserID int64
LoginSourceID int64
HasRefreshToken bool
Expired bool
OrderBy string
}
FindExternalUserOptions represents an options to find external users
func (FindExternalUserOptions) ToConds ¶
func (opts FindExternalUserOptions) ToConds() builder.Cond
func (FindExternalUserOptions) ToOrders ¶
func (opts FindExternalUserOptions) ToOrders() string
type Follow ¶
type Follow struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"UNIQUE(follow)"`
FollowID int64 `xorm:"UNIQUE(follow)"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
}
Follow represents relations of user and their followers.
type Meta ¶
type Meta struct {
// Store the initial registration of the user, to aid in spam prevention
// Ensure that one IP isn't creating many accounts (following mediawiki approach)
InitialIP string
InitialUserAgent string
}
Meta defines the meta information of a user, to be stored in the K/V table
type PinnedRepo ¶
type PinnedRepo struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"INDEX NOT NULL"`
RepoID int64 `xorm:"INDEX NOT NULL"`
DisplayOrder int `xorm:"DEFAULT 0"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
Repo any `xorm:"-"` // Will be loaded by caller to avoid import cycle
}
PinnedRepo represents a pinned repository for a user's profile
func GetPinnedRepos ¶
func GetPinnedRepos(ctx context.Context, userID int64) ([]*PinnedRepo, error)
GetPinnedRepos returns all pinned repos for a user
func (*PinnedRepo) TableName ¶
func (p *PinnedRepo) TableName() string
TableName returns the table name for PinnedRepo
type Redirect ¶
type Redirect struct {
ID int64 `xorm:"pk autoincr"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
RedirectUserID int64 // userID to redirect to
}
Redirect represents that a user name should be redirected to another
type SearchEmailOptions ¶
type SearchEmailOptions struct {
db.ListOptions
Keyword string
SortType SearchEmailOrderBy
IsPrimary optional.Option[bool]
IsActivated optional.Option[bool]
}
SearchEmailOptions are options to search e-mail addresses for the admin panel
type SearchEmailOrderBy ¶
type SearchEmailOrderBy string
SearchEmailOrderBy is used to sort the results from SearchEmails()
const ( SearchEmailOrderByEmail SearchEmailOrderBy = "email_address.lower_email ASC, email_address.is_primary DESC, email_address.id ASC" SearchEmailOrderByEmailReverse SearchEmailOrderBy = "email_address.lower_email DESC, email_address.is_primary ASC, email_address.id DESC" SearchEmailOrderByName SearchEmailOrderBy = "`user`.lower_name ASC, email_address.is_primary DESC, email_address.id ASC" SearchEmailOrderByNameReverse SearchEmailOrderBy = "`user`.lower_name DESC, email_address.is_primary ASC, email_address.id DESC" )
Strings for sorting result
func (SearchEmailOrderBy) String ¶
func (s SearchEmailOrderBy) String() string
type SearchEmailResult ¶
type SearchEmailResult struct {
ID int64
UID int64
Email string
IsActivated bool
IsPrimary bool
// From User
Name string
FullName string
}
SearchEmailResult is an e-mail address found in the user or email_address table
func SearchEmails ¶
func SearchEmails(ctx context.Context, opts *SearchEmailOptions) ([]*SearchEmailResult, int64, error)
SearchEmails takes options i.e. keyword and part of email name to search, it returns results in given range and number of total results.
type SearchOrganizationsOptions ¶
type SearchOrganizationsOptions struct {
db.ListOptions
All bool
}
SearchOrganizationsOptions options to filter organizations
type SearchUserOptions ¶
type SearchUserOptions struct {
db.ListOptions
Keyword string
Types []UserType
UID int64
LoginName string // this option should be used only for admin user
SourceID int64 // this option should be used only for admin user
OrderBy db.SearchOrderBy
Visible []structs.VisibleType
Actor *User // The user doing the search
SearchByEmail bool // Search by email as well as username/full name
SupportedSortOrders container.Set[string] // if not nil, only allow to use the sort orders in this set
IsActive optional.Option[bool]
IsAdmin optional.Option[bool]
IsRestricted optional.Option[bool]
IsTwoFactorEnabled optional.Option[bool]
IsProhibitLogin optional.Option[bool]
IncludeReserved bool
}
SearchUserOptions contains the options for searching
type Setting ¶
type Setting struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 `xorm:"index unique(key_userid)"` // to load all of someone's settings
SettingKey string `xorm:"varchar(255) index unique(key_userid)"` // ensure key is always lowercase
SettingValue string `xorm:"text"`
}
Setting is a key value store of user settings
func GetSettingNoCache ¶
GetSettingNoCache returns specific setting without using the cache
type TimeLimitCodeOptions ¶
type TimeLimitCodeOptions struct {
Purpose TimeLimitCodePurpose
NewEmail string
}
type TimeLimitCodePurpose ¶
type TimeLimitCodePurpose string
const ( TimeLimitCodeActivateAccount TimeLimitCodePurpose = "activate_account" TimeLimitCodeActivateEmail TimeLimitCodePurpose = "activate_email" TimeLimitCodeResetPassword TimeLimitCodePurpose = "reset_password" )
type User ¶
type User struct {
ID int64 `xorm:"pk autoincr"`
LowerName string `xorm:"UNIQUE NOT NULL"`
Name string `xorm:"UNIQUE NOT NULL"`
FullName string
// Email is the primary email address (to be used for communication)
Email string `xorm:"NOT NULL"`
KeepEmailPrivate bool
EmailNotificationsPreference string `xorm:"VARCHAR(20) NOT NULL DEFAULT 'enabled'"`
Passwd string `xorm:"NOT NULL"`
PasswdHashAlgo string `xorm:"NOT NULL DEFAULT 'argon2'"`
// MustChangePassword is an attribute that determines if a user
// is to change their password after registration.
MustChangePassword bool `xorm:"NOT NULL DEFAULT false"`
LoginType auth.Type
LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
LoginName string
Type UserType
Location string
Website string
Rands string `xorm:"VARCHAR(32)"`
Salt string `xorm:"VARCHAR(32)"`
Language string `xorm:"VARCHAR(5)"`
Description string
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
LastLoginUnix timeutil.TimeStamp `xorm:"INDEX"`
// Remember visibility choice for convenience, true for private
LastRepoVisibility bool
// Maximum repository creation limit, -1 means use global default
MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1"`
// IsActive true: primary email is activated, user can access Web UI and Git SSH.
// false: an inactive user can only log in Web UI for account operations (ex: activate the account by email), no other access.
IsActive bool `xorm:"INDEX"`
// the user is a Gitea admin, who can access all repositories and the admin pages.
IsAdmin bool
// true: the user is only allowed to see organizations/repositories that they has explicit rights to.
// (ex: in private Gitea instances user won't be allowed to see even organizations/repositories that are set as public)
IsRestricted bool `xorm:"NOT NULL DEFAULT false"`
// IsHomepagePinned indicates if this organization should appear on the homepage
IsHomepagePinned bool `xorm:"NOT NULL DEFAULT false"`
AllowGitHook bool
AllowImportLocal bool // Allow migrate repository by local path
AllowCreateOrganization bool `xorm:"DEFAULT true"`
// true: the user is not allowed to log in Web UI. Git/SSH access could still be allowed (please refer to Git/SSH access related code/documents)
ProhibitLogin bool `xorm:"NOT NULL DEFAULT false"`
// Avatar
Avatar string `xorm:"VARCHAR(2048) NOT NULL"`
AvatarEmail string `xorm:"NOT NULL"`
UseCustomAvatar bool
// Counters
NumFollowers int
NumFollowing int `xorm:"NOT NULL DEFAULT 0"`
NumStars int
NumRepos int
// For organization
NumTeams int
NumMembers int
Visibility structs.VisibleType `xorm:"NOT NULL DEFAULT 0"`
RepoAdminChangeTeamAccess bool `xorm:"NOT NULL DEFAULT false"`
GroupHeader string `xorm:"VARCHAR(255)"`
// Preferences
DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`
Theme string `xorm:"NOT NULL DEFAULT ''"`
KeepActivityPrivate bool `xorm:"NOT NULL DEFAULT false"`
ShowHeatmapOnProfile bool `xorm:"NOT NULL DEFAULT false"`
}
User represents the object of individual and member of organization.
func GetAdminUser ¶
GetAdminUser returns the first administrator
func GetAllUsers ¶
GetAllUsers returns a slice of all individual users found in DB.
func GetInactiveUsers ¶
GetInactiveUsers gets all inactive users
func GetMailableUsersByIDs ¶
GetMailableUsersByIDs gets users from ids, but only if they can receive mails
func GetPossibleUserByID ¶
GetPossibleUserByID returns the user if id > 0 or returns system user if id < 0
func GetPossibleUserByIDs ¶
GetPossibleUserByIDs returns the users if id > 0 or returns system users if id < 0
func GetPossibleUserFromMap ¶
func GetUserByEmail ¶
GetUserByEmail returns the user object by given e-mail if exists.
func GetUserByID ¶
GetUserByID returns the user object by given ID if exists.
func GetUserByIDs ¶
GetUserByIDs returns the user objects by given IDs if exists.
func GetUserByName ¶
GetUserByName returns user by given name.
func GetUserByOpenID ¶
GetUserByOpenID returns the user object by given OpenID if exists.
func GetUserFollowers ¶
func GetUserFollowers(ctx context.Context, u, viewer *User, listOptions db.ListOptions) ([]*User, int64, error)
GetUserFollowers returns range of user's followers.
func GetUserFollowing ¶
func GetUserFollowing(ctx context.Context, u, viewer *User, listOptions db.ListOptions) ([]*User, int64, error)
GetUserFollowing returns range of user's following.
func GetUserOrOrgByName ¶
GetUserOrOrgByName returns the user or org by name
func GetUsersBySource ¶
GetUsersBySource returns a list of Users for a login source
func GetVerifyUser ¶
GetVerifyUser get user by verify code
func NewActionsUser ¶
func NewActionsUser() *User
NewActionsUser creates and returns a fake user for running the actions.
func NewGhostUser ¶
func NewGhostUser() *User
NewGhostUser creates and returns a fake user for someone has deleted their account.
func SearchUsers ¶
SearchUsers takes options i.e. keyword and part of user name to search, it returns results in given range and number of total results.
func ValidateCommitWithEmail ¶
ValidateCommitWithEmail check if author's e-mail of commit is corresponding to a user.
func VerifyUserTimeLimitCode ¶
func VerifyUserTimeLimitCode(ctx context.Context, opts *TimeLimitCodeOptions, code string) (user *User)
VerifyUserTimeLimitCode verifies the time-limit code
func (*User) AfterLoad ¶
func (u *User) AfterLoad()
AfterLoad is invoked from XORM after filling all the fields of this object.
func (*User) AvatarLink ¶
AvatarLink returns the full avatar url with http host. TODO: refactor it to a relative URL, but it is still used in API response at the moment
func (*User) AvatarLinkWithSize ¶
AvatarLinkWithSize returns a link to the user's avatar with size. size <= 0 means default size
func (*User) BeforeUpdate ¶
func (u *User) BeforeUpdate()
BeforeUpdate is invoked from XORM before updating this object.
func (*User) CanCreateOrganization ¶
CanCreateOrganization returns true if user can create organisation.
func (*User) CanCreateRepoIn ¶
CanCreateRepoIn checks whether the doer(u) can create a repository in the owner NOTE: functions calling this assume a failure due to repository count limit, or the owner is not a real user. It ONLY checks the repo number LIMIT or whether owner user is real. If new checks are added, those functions should be revised. TODO: the callers can only return ErrReachLimitOfRepo, need to fine tune to support other error types in the future.
func (*User) CanEditGitHook ¶
CanEditGitHook returns true if user can edit Git hooks.
func (*User) CanForkRepoIn ¶
CanForkRepoIn ONLY checks repository count limit
func (*User) CanImportLocal ¶
CanImportLocal returns true if user can migrate repository by local path.
func (*User) CustomAvatarRelativePath ¶
CustomAvatarRelativePath returns user custom avatar relative path.
func (*User) DashboardLink ¶
DashboardLink returns the user dashboard page link.
func (*User) DisplayName ¶
DisplayName returns full name if it's not empty, returns username otherwise.
func (*User) EmailTo ¶
EmailTo returns a string suitable to be put into a e-mail `To:` header.
func (*User) GetCompleteName ¶
GetCompleteName returns the full name and username in the form of "Full Name (username)" if full name is not empty, otherwise it returns "username".
func (*User) GetDisplayName ¶
GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set, returns username otherwise.
func (*User) GetEmail ¶
GetEmail returns a noreply email, if the user has set to keep his email address private, otherwise the primary email address.
func (*User) GetPlaceholderEmail ¶
GetPlaceholderEmail returns an noreply email
func (*User) HTMLURL ¶
HTMLURL returns the user or organization's full link.
func (*User) HomeLink ¶
HomeLink returns the user or organization home page link.
func (*User) IsGhost ¶
IsGhost check if user is fake user for a deleted account
func (*User) IsIndividual ¶
IsIndividual returns true if user is actually a individual user.
func (*User) IsLocal ¶
IsLocal returns true if user login type is LoginPlain.
func (*User) IsMailable ¶
IsMailable checks if a user is eligible to receive emails.
func (*User) IsOAuth2 ¶
IsOAuth2 returns true if user login type is LoginOAuth2.
func (*User) IsOrganization ¶
IsOrganization returns true if user is actually an organization.
func (*User) IsPasswordSet ¶
IsPasswordSet checks if the password is set or left empty TODO: It's better to clarify the "password" behavior for different types (individual, bot)
func (*User) IsTokenAccessAllowed ¶
IsTokenAccessAllowed returns whether the user is an individual or a bot (which allows for token access)
func (*User) IsTypeBot ¶
IsTypeBot returns whether the user is of type bot
func (*User) IsUploadAvatarChanged ¶
IsUploadAvatarChanged returns true if the current user's avatar would be changed with the provided data
func (*User) MaxCreationLimit ¶
MaxCreationLimit returns the number of repositories a user is allowed to create
func (*User) NewGitSig ¶
NewGitSig generates and returns the signature of given user.
func (*User) OrganisationLink ¶
OrganisationLink returns the organization sub page link.
func (*User) SetPassword ¶
SetPassword hashes a password using the algorithm defined in the config value of PASSWORD_HASH_ALGO change passwd, salt and passwd_hash_algo fields
func (*User) ShortName ¶
ShortName ellipses username to length
type UserBadge ¶
UserBadge represents a user badge
type UserCommit ¶
UserCommit represents a commit with validation of user.
type UserList ¶
type UserList []*User //revive:disable-line:exported
UserList is a list of user. This type provide valuable methods to retrieve information for a group of users efficiently.
func GetUsersByIDs ¶
GetUsersByIDs returns all resolved users from a list of Ids.
func (UserList) GetTwoFaStatus ¶
GetTwoFaStatus return state of 2FA enrollement
type UserOpenID ¶
type UserOpenID struct {
ID int64 `xorm:"pk autoincr"`
UID int64 `xorm:"INDEX NOT NULL"`
URI string `xorm:"UNIQUE NOT NULL"`
Show bool `xorm:"DEFAULT false"`
}
UserOpenID is the list of all OpenID identities of a user. Since this is a middle table, name it OpenID is not suitable, so we ignore the lint here
type UserType ¶
type UserType int //revive:disable-line:exported
UserType defines the user type
const ( // UserTypeIndividual defines an individual user UserTypeIndividual UserType = iota // Historic reason to make it starts at 0. // UserTypeOrganization defines an organization UserTypeOrganization // 1 // UserTypeUserReserved reserves a (non-existing) user, i.e. to prevent a spam user from re-registering after being deleted, or to reserve the name until the user is actually created later on UserTypeUserReserved // 2 // UserTypeOrganizationReserved reserves a (non-existing) organization, to be used in combination with UserTypeUserReserved UserTypeOrganizationReserved // 3 // UserTypeBot defines a bot user UserTypeBot // 4 // UserTypeRemoteUser defines a remote user for federated users UserTypeRemoteUser // 5 )
Source Files
¶
- avatar.go
- badge.go
- block.go
- email_address.go
- error.go
- external_login_user.go
- follow.go
- list.go
- must_change_password.go
- openid.go
- redirect.go
- search.go
- setting.go
- setting_options.go
- user.go
- user_list.go
- user_pinned.go
- user_system.go
- user_update.go