Documentation ¶
Index ¶
- Constants
- Variables
- func ActivateEmail(email *EmailAddress) error
- func ActivateUserEmail(userID int64, email string, activate bool) (err error)
- func AddEmailAddress(email *EmailAddress) error
- func AddEmailAddresses(emails []*EmailAddress) error
- func AddUserOpenID(openid *UserOpenID) error
- func ChangeUserName(u *User, newUserName string) (err error)
- func CountUsers() int64
- func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err error)
- func DeleteEmailAddress(email *EmailAddress) (err error)
- func DeleteEmailAddresses(emails []*EmailAddress) (err error)
- func DeleteInactiveEmailAddresses(ctx context.Context) error
- func DeleteSetting(setting *Setting) error
- func DeleteUserOpenID(openid *UserOpenID) (err error)
- func DeleteUserRedirect(ctx context.Context, userName string) error
- func FollowUser(userID, followID int64) (err error)
- func GenerateRandomAvatar(u *User) error
- func GenerateRandomAvatarCtx(ctx context.Context, u *User) error
- func GetExternalLogin(externalLoginUser *ExternalLoginUser) (bool, error)
- func GetSettings(uid int64, keys []string) (map[string]*Setting, error)
- func GetUser(user *User) (bool, error)
- func GetUserAllSettings(uid int64) (map[string]*Setting, error)
- func GetUserEmailsByNames(names []string) []string
- func GetUserIDByExternalUserID(provider, userID string) (int64, error)
- func GetUserIDsByNames(names []string, ignoreNonExistent bool) ([]int64, error)
- func GetUserNamesByIDs(ids []int64) ([]string, error)
- func GetUserSalt() (string, error)
- func IsEmailActive(ctx context.Context, email string, excludeEmailID int64) (bool, error)
- func IsEmailUsed(ctx context.Context, email string) (bool, error)
- 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 IsErrPrimaryEmailCannotDelete(err error) bool
- func IsErrUserAlreadyExist(err error) bool
- func IsErrUserInactive(err error) bool
- func IsErrUserNotExist(err error) bool
- func IsErrUserProhibitLogin(err error) bool
- func IsErrUserRedirectNotExist(err error) bool
- func IsFollowing(userID, followID int64) bool
- func IsUsableUsername(name string) error
- func IsUserExist(uid int64, name string) (bool, error)
- func IterateUser(f func(user *User) error) error
- func LinkExternalToUser(user *User, externalLoginUser *ExternalLoginUser) error
- func LookupUserRedirect(userName string) (int64, error)
- func MakeEmailPrimary(email *EmailAddress) error
- func NewUserRedirect(ctx context.Context, ID int64, oldUserName, newUserName string) error
- func RemoveAccountLink(user *User, loginSourceID int64) (int64, error)
- func RemoveAllAccountLinks(ctx context.Context, user *User) error
- func SetEmailNotifications(u *User, set string) error
- func SetSetting(setting *Setting) error
- func ToggleUserOpenIDVisibility(id int64) (err error)
- func UnfollowUser(userID, followID int64) (err error)
- func UpdateExternalUserByExternalID(external *ExternalLoginUser) error
- func UpdateUser(u *User, emailChanged bool, cols ...string) error
- func UpdateUserCols(ctx context.Context, u *User, cols ...string) error
- func UpdateUserColsEngine(e db.Engine, u *User, cols ...string) error
- func UpdateUserDiffViewStyle(u *User, style string) error
- func UpdateUserSetting(u *User) (err error)
- func UpdateUserTheme(u *User, themeName string) error
- func UserPath(userName string) string
- func ValidateEmail(email string) error
- type CreateUserOverwriteOptions
- type EmailAddress
- type ErrEmailAddressNotExist
- type ErrEmailAlreadyUsed
- type ErrEmailCharIsNotSupported
- type ErrEmailInvalid
- type ErrExternalLoginUserAlreadyExist
- type ErrExternalLoginUserNotExist
- type ErrOpenIDAlreadyUsed
- type ErrPrimaryEmailCannotDelete
- type ErrUserAlreadyExist
- type ErrUserInactive
- type ErrUserNotExist
- type ErrUserProhibitLogin
- type ErrUserRedirectNotExist
- type ExternalLoginUser
- type FindExternalUserOptions
- type Follow
- type Redirect
- type SearchEmailOptions
- type SearchEmailOrderBy
- type SearchEmailResult
- type SearchOrganizationsOptions
- type SearchUserOptions
- type Setting
- type User
- func GetAdminUser() (*User, error)
- func GetAllUsers() ([]*User, error)
- func GetInactiveUsers(ctx context.Context, olderThan time.Duration) ([]*User, error)
- func GetMaileableUsersByIDs(ids []int64, isMention bool) ([]*User, error)
- func GetUserByEmail(email string) (*User, error)
- func GetUserByEmailContext(ctx context.Context, email string) (*User, error)
- func GetUserByID(id int64) (*User, error)
- func GetUserByIDCtx(ctx context.Context, id int64) (*User, error)
- func GetUserByIDEngine(e db.Engine, id int64) (*User, error)
- func GetUserByName(name string) (*User, error)
- func GetUserByNameCtx(ctx context.Context, name string) (*User, error)
- func GetUserByOpenID(uri string) (*User, error)
- func GetUserFollowers(u *User, listOptions db.ListOptions) ([]*User, error)
- func GetUserFollowing(u *User, listOptions db.ListOptions) ([]*User, error)
- func GetUsersBySource(s *auth.Source) ([]*User, error)
- func GetVerifyUser(code string) (user *User)
- func NewGhostUser() *User
- func NewReplaceUser(name string) *User
- func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error)
- func ValidateCommitWithEmail(c *git.Commit) *User
- func VerifyUserActiveCode(code string) (user *User)
- func (u *User) AfterLoad()
- func (u *User) AvatarLink() string
- func (u *User) AvatarLinkWithSize(size int) string
- func (u *User) BeforeUpdate()
- func (u *User) CanCreateOrganization() bool
- func (u *User) CanCreateRepo() bool
- func (u *User) CanEditGitHook() bool
- func (u *User) CanImportLocal() bool
- func (u *User) ColorFormat(s fmt.State)
- func (u *User) CustomAvatarRelativePath() string
- func (u *User) DashboardLink() string
- func (u *User) DisplayName() string
- func (u *User) EmailNotifications() string
- func (u *User) GenerateEmailActivateCode(email string) string
- func (u *User) GetDisplayName() string
- func (u *User) GetEmail() string
- func (u *User) GitName() string
- func (u *User) HTMLURL() string
- func (u *User) HomeLink() string
- func (u *User) IsGhost() 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) IsUploadAvatarChanged(data []byte) bool
- 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 UserCommit
- type UserList
- type UserOpenID
- type UserType
Constants ¶
const ( // EmailNotificationsEnabled indicates that the user would like to receive all email notifications 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" )
const SaltByteLength = 16
Note: 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 AvailableHashAlgorithms = []string{
algoPbkdf2,
algoArgon2,
algoScrypt,
algoBcrypt,
}
AvailableHashAlgorithms represents the available password hashing algorithms
var ErrEmailNotActivated = errors.New("e-mail address has not been activated")
ErrEmailNotActivated e-mail address has not been activated error
var ErrOpenIDNotExist = errors.New("OpenID is unknown")
ErrOpenIDNotExist openid is not known
Functions ¶
func ActivateEmail ¶
func ActivateEmail(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 AddEmailAddress ¶
func AddEmailAddress(email *EmailAddress) error
AddEmailAddress adds an email address to given user.
func AddEmailAddresses ¶
func AddEmailAddresses(emails []*EmailAddress) error
AddEmailAddresses adds an email address to given user.
func AddUserOpenID ¶
func AddUserOpenID(openid *UserOpenID) error
AddUserOpenID adds an pre-verified/normalized OpenID URI to given user.
func ChangeUserName ¶
ChangeUserName changes all corresponding setting from old user name to new one.
func CreateUser ¶
func CreateUser(u *User, overwriteDefault ...*CreateUserOverwriteOptions) (err error)
CreateUser creates record of a new user.
func DeleteEmailAddress ¶
func DeleteEmailAddress(email *EmailAddress) (err error)
DeleteEmailAddress deletes an email address of given user.
func DeleteEmailAddresses ¶
func DeleteEmailAddresses(emails []*EmailAddress) (err error)
DeleteEmailAddresses deletes multiple email addresses
func DeleteInactiveEmailAddresses ¶
DeleteInactiveEmailAddresses deletes inactive email addresses
func DeleteSetting ¶
DeleteSetting deletes a specific setting for a user
func DeleteUserOpenID ¶
func DeleteUserOpenID(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 FollowUser ¶
FollowUser marks someone be another's follower.
func GenerateRandomAvatar ¶
GenerateRandomAvatar generates a random avatar for user.
func GenerateRandomAvatarCtx ¶
GenerateRandomAvatarCtx generates a random avatar for user.
func GetExternalLogin ¶
func GetExternalLogin(externalLoginUser *ExternalLoginUser) (bool, error)
GetExternalLogin checks if a externalID in loginSourceID scope already exists
func GetSettings ¶
GetSettings returns specific settings from user
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 ¶
GetUserIDsByNames returns a slice of ids corresponds to names.
func GetUserNamesByIDs ¶
GetUserNamesByIDs returns usernames for all resolved users from a list of Ids.
func IsEmailActive ¶
IsEmailActive check if email is activated with a different emailID
func IsEmailUsed ¶
IsEmailUsed returns true if the email has been used.
func IsErrEmailAddressNotExist ¶
IsErrEmailAddressNotExist checks if an error is an ErrEmailAddressNotExist
func IsErrEmailAlreadyUsed ¶
IsErrEmailAlreadyUsed checks if an error is a ErrEmailAlreadyUsed.
func IsErrEmailCharIsNotSupported ¶ added in v1.16.4
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 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 IsFollowing ¶
IsFollowing returns true if user is following followID.
func IsUsableUsername ¶
IsUsableUsername returns an error when a username is reserved
func IsUserExist ¶
IsUserExist checks if given user name exist, the user name should be noncased unique. If uid is presented, then check will rule out that one, it is used when update a user name in settings page.
func LinkExternalToUser ¶
func LinkExternalToUser(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 MakeEmailPrimary ¶
func MakeEmailPrimary(email *EmailAddress) error
MakeEmailPrimary sets primary email address of given user.
func NewUserRedirect ¶
NewUserRedirect create a new user redirect
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 SetEmailNotifications ¶
SetEmailNotifications sets the user's email notification preference
func SetSetting ¶
SetSetting 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 UpdateExternalUserByExternalID ¶
func UpdateExternalUserByExternalID(external *ExternalLoginUser) error
UpdateExternalUserByExternalID updates an external user's information
func UpdateUser ¶
UpdateUser updates user's information.
func UpdateUserCols ¶
UpdateUserCols update user according special columns
func UpdateUserColsEngine ¶
UpdateUserColsEngine update user according special columns
func UpdateUserDiffViewStyle ¶
UpdateUserDiffViewStyle updates the users diff view style
func UpdateUserSetting ¶
UpdateUserSetting updates user's settings.
func UpdateUserTheme ¶
UpdateUserTheme updates a users' theme irrespective of the site wide theme
func ValidateEmail ¶
ValidateEmail check if email is a allowed address
Types ¶
type CreateUserOverwriteOptions ¶
type CreateUserOverwriteOptions struct {
Visibility structs.VisibleType
}
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 GetEmailAddressByID ¶
func GetEmailAddressByID(uid, id int64) (*EmailAddress, error)
GetEmailAddressByID gets a user's email address by ID
func GetEmailAddresses ¶
func GetEmailAddresses(uid int64) ([]*EmailAddress, error)
GetEmailAddresses returns all email addresses belongs to given user.
func VerifyActiveEmailCode ¶
func VerifyActiveEmailCode(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 ErrEmailAddressNotExist ¶
type ErrEmailAddressNotExist struct {
Email string
}
ErrEmailAddressNotExist email address not exist
func (ErrEmailAddressNotExist) Error ¶
func (err ErrEmailAddressNotExist) Error() string
type ErrEmailAlreadyUsed ¶
type ErrEmailAlreadyUsed struct {
Email string
}
ErrEmailAlreadyUsed represents a "EmailAlreadyUsed" kind of error.
func (ErrEmailAlreadyUsed) Error ¶
func (err ErrEmailAlreadyUsed) Error() string
type ErrEmailCharIsNotSupported ¶ added in v1.16.4
type ErrEmailCharIsNotSupported struct {
Email string
}
ErrEmailCharIsNotSupported e-mail address contains unsupported character
func (ErrEmailCharIsNotSupported) Error ¶ added in v1.16.4
func (err ErrEmailCharIsNotSupported) Error() string
type ErrEmailInvalid ¶
type ErrEmailInvalid struct {
Email string
}
ErrEmailInvalid represents an error where the email address does not comply with RFC 5322
func (ErrEmailInvalid) Error ¶
func (err ErrEmailInvalid) Error() string
type ErrExternalLoginUserAlreadyExist ¶
ErrExternalLoginUserAlreadyExist represents a "ExternalLoginUserAlreadyExist" kind of error.
func (ErrExternalLoginUserAlreadyExist) Error ¶
func (err ErrExternalLoginUserAlreadyExist) Error() string
type ErrExternalLoginUserNotExist ¶
ErrExternalLoginUserNotExist represents a "ExternalLoginUserNotExist" kind of error.
func (ErrExternalLoginUserNotExist) Error ¶
func (err ErrExternalLoginUserNotExist) Error() string
type ErrOpenIDAlreadyUsed ¶
type ErrOpenIDAlreadyUsed struct {
OpenID string
}
ErrOpenIDAlreadyUsed represents a "OpenIDAlreadyUsed" kind of error.
func (ErrOpenIDAlreadyUsed) Error ¶
func (err ErrOpenIDAlreadyUsed) Error() string
type ErrPrimaryEmailCannotDelete ¶
type ErrPrimaryEmailCannotDelete struct {
Email string
}
ErrPrimaryEmailCannotDelete primary email address cannot be deleted
func (ErrPrimaryEmailCannotDelete) Error ¶
func (err ErrPrimaryEmailCannotDelete) Error() string
type ErrUserAlreadyExist ¶
type ErrUserAlreadyExist struct {
Name string
}
ErrUserAlreadyExist represents a "user already exists" error.
func (ErrUserAlreadyExist) Error ¶
func (err ErrUserAlreadyExist) Error() string
type ErrUserInactive ¶
ErrUserInactive represents a "ErrUserInactive" kind of error.
func (ErrUserInactive) Error ¶
func (err ErrUserInactive) Error() string
type ErrUserNotExist ¶
ErrUserNotExist represents a "UserNotExist" kind of error.
func (ErrUserNotExist) Error ¶
func (err ErrUserNotExist) Error() string
type ErrUserProhibitLogin ¶
ErrUserProhibitLogin represents a "ErrUserProhibitLogin" kind of error.
func (ErrUserProhibitLogin) Error ¶
func (err ErrUserProhibitLogin) Error() string
type ErrUserRedirectNotExist ¶
type ErrUserRedirectNotExist struct {
Name string
}
ErrUserRedirectNotExist represents a "UserRedirectNotExist" kind of error.
func (ErrUserRedirectNotExist) Error ¶
func (err ErrUserRedirectNotExist) Error() string
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]interface{} `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
func FindExternalUsersByProvider ¶
func FindExternalUsersByProvider(opts FindExternalUserOptions) ([]ExternalLoginUser, error)
FindExternalUsersByProvider represents external users via provider
func ListAccountLinks ¶
func ListAccountLinks(user *User) ([]*ExternalLoginUser, error)
ListAccountLinks returns a map with the ExternalLoginUser and its LoginSource
type FindExternalUserOptions ¶
FindExternalUserOptions represents an options to find external users
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 his/her followers.
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 util.OptionalBool IsActivated util.OptionalBool }
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 { 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(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 Type UserType UID int64 OrderBy db.SearchOrderBy Visible []structs.VisibleType Actor *User // The user doing the search SearchByEmail bool // Search by email as well as username/full name IsActive util.OptionalBool IsAdmin util.OptionalBool IsRestricted util.OptionalBool IsTwoFactorEnabled util.OptionalBool IsProhibitLogin util.OptionalBool ExtraParamStrings map[string]string }
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
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 his/her 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"` 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"` // Preferences DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"` Theme string `xorm:"NOT NULL DEFAULT ''"` KeepActivityPrivate bool `xorm:"NOT NULL DEFAULT false"` }
User represents the object of individual and member of organization.
func GetAllUsers ¶
GetAllUsers returns a slice of all individual users found in DB.
func GetInactiveUsers ¶
GetInactiveUsers gets all inactive users
func GetMaileableUsersByIDs ¶
GetMaileableUsersByIDs gets users from ids, but only if they can receive mails
func GetUserByEmail ¶
GetUserByEmail returns the user object by given e-mail if exists.
func GetUserByEmailContext ¶
GetUserByEmailContext returns the user object by given e-mail if exists with db context
func GetUserByID ¶
GetUserByID returns the user object by given ID if exists.
func GetUserByIDCtx ¶
GetUserByIDCtx returns the user object by given ID if exists.
func GetUserByIDEngine ¶
GetUserByIDEngine returns the user object by given ID if exists.
func GetUserByName ¶
GetUserByName returns user by given name.
func GetUserByNameCtx ¶
GetUserByNameCtx returns user by given name.
func GetUserByOpenID ¶
GetUserByOpenID returns the user object by given OpenID if exists.
func GetUserFollowers ¶
func GetUserFollowers(u *User, listOptions db.ListOptions) ([]*User, error)
GetUserFollowers returns range of user's followers.
func GetUserFollowing ¶
func GetUserFollowing(u *User, listOptions db.ListOptions) ([]*User, error)
GetUserFollowing returns range of user's following.
func GetUsersBySource ¶
GetUsersBySource returns a list of Users for a login source
func GetVerifyUser ¶
GetVerifyUser get user by verify code
func NewGhostUser ¶
func NewGhostUser() *User
NewGhostUser creates and returns a fake user for someone has deleted his/her account.
func NewReplaceUser ¶
NewReplaceUser creates and returns a fake user for external user
func SearchUsers ¶
func SearchUsers(opts *SearchUserOptions) (users []*User, _ int64, _ error)
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 VerifyUserActiveCode ¶
VerifyUserActiveCode verifies active code when active account
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 link with http host
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) CanCreateRepo ¶
CanCreateRepo returns if user login can create a repository NOTE: functions calling this assume a failure due to repository count limit; if new checks are added, those functions should be revised
func (*User) CanEditGitHook ¶
CanEditGitHook returns true if user can edit Git hooks.
func (*User) CanImportLocal ¶
CanImportLocal returns true if user can migrate repository by local path.
func (*User) ColorFormat ¶
ColorFormat writes a colored string to identify this struct
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) EmailNotifications ¶
EmailNotifications returns the User's email notification preference
func (*User) GenerateEmailActivateCode ¶
GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
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 an noreply email, if the user has set to keep his email address private, otherwise the primary email address.
func (*User) IsMailable ¶
IsMailable checks if a user is eligible to receive emails.
func (*User) IsOrganization ¶
IsOrganization returns true if user is actually a organization.
func (*User) IsPasswordSet ¶
IsPasswordSet checks if the password is set or left empty
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) 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) ValidatePassword ¶
ValidatePassword checks if given password matches the one belongs to the user.
type UserCommit ¶
UserCommit represents a commit with validation of user.
func ValidateCommitsWithEmails ¶
func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit
ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
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
func (UserList) GetUserIDs ¶
GetUserIDs returns a slice of user's id
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
func GetUserOpenIDs ¶
func GetUserOpenIDs(uid int64) ([]*UserOpenID, error)
GetUserOpenIDs returns all openid addresses that belongs to given user.