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