Documentation ¶
Index ¶
- Constants
- Variables
- func CheckEmailDomain(email string, domains string) bool
- func CheckUserDomain(user *model.User, domains string) bool
- func CheckUserPassword(user *model.User, password string) error
- func ComparePassword(hash string, password string) error
- func HashPassword(password string) string
- func IsPasswordValidWithSettings(password string, settings *model.PasswordSettings) error
- type ErrInvalidPassword
- type ServiceConfig
- type UserCreateOptions
- type UserService
- func (us *UserService) ActivateMfa(user *model.User, token string) error
- func (us *UserService) AddSessionToCache(session *model.Session)
- func (us *UserService) ClearAllUsersSessionCache()
- func (us *UserService) ClearAllUsersSessionCacheLocal()
- func (us *UserService) ClearUserSessionCache(userID string)
- func (us *UserService) ClearUserSessionCacheLocal(userID string)
- func (us *UserService) CreateSession(session *model.Session) (*model.Session, error)
- func (us *UserService) CreateUser(user *model.User, opts UserCreateOptions) (*model.User, error)
- func (us *UserService) DeactivateAllGuests() ([]string, error)
- func (us *UserService) DeactivateMfa(user *model.User) error
- func (us *UserService) DemoteUserToGuest(user *model.User) (*model.User, error)
- func (us *UserService) ExtendSessionExpiry(session *model.Session, newExpiry int64) error
- func (us *UserService) FileBackend() (filestore.FileBackend, error)
- func (us *UserService) GenerateMfaSecret(user *model.User) (*model.MfaSecret, error)
- func (us *UserService) GetDefaultProfileImage(user *model.User) ([]byte, error)
- func (us *UserService) GetProfileImage(user *model.User) ([]byte, bool, error)
- func (us *UserService) GetSanitizeOptions(asAdmin bool) map[string]bool
- func (us *UserService) GetSession(token string) (*model.Session, error)
- func (us *UserService) GetSessionByID(sessionID string) (*model.Session, error)
- func (us *UserService) GetSessionContext(ctx context.Context, token string) (*model.Session, error)
- func (us *UserService) GetSessions(userID string) ([]*model.Session, error)
- func (us *UserService) GetUser(userID string) (*model.User, error)
- func (us *UserService) GetUserByAuth(authData *string, authService string) (*model.User, error)
- func (us *UserService) GetUserByEmail(email string) (*model.User, error)
- func (us *UserService) GetUserByUsername(username string) (*model.User, error)
- func (us *UserService) GetUsers(options *model.UserGetOptions) ([]*model.User, error)
- func (us *UserService) GetUsersByIds(userIDs []string, options *store.UserGetByIdsOpts) ([]*model.User, error)
- func (us *UserService) GetUsersByUsernames(usernames []string, options *model.UserGetOptions) ([]*model.User, error)
- func (us *UserService) GetUsersEtag(restrictionsHash string) string
- func (us *UserService) GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, error)
- func (us *UserService) GetUsersInTeamEtag(teamID string, restrictionsHash string) string
- func (us *UserService) GetUsersInTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, error)
- func (us *UserService) GetUsersNotInTeam(teamID string, groupConstrained bool, offset int, limit int, ...) ([]*model.User, error)
- func (us *UserService) GetUsersNotInTeamEtag(teamID string, restrictionsHash string) string
- func (us *UserService) GetUsersNotInTeamPage(teamID string, groupConstrained bool, page int, perPage int, asAdmin bool, ...) ([]*model.User, error)
- func (us *UserService) GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, error)
- func (us *UserService) GetUsersWithoutTeam(options *model.UserGetOptions) ([]*model.User, error)
- func (us *UserService) GetUsersWithoutTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, error)
- func (us *UserService) InvalidateCacheForUser(userID string)
- func (us *UserService) IsFirstUserAccount() bool
- func (us *UserService) IsUsernameTaken(name string) bool
- func (us *UserService) PromoteGuestToUser(user *model.User) error
- func (us *UserService) ReadFile(path string) ([]byte, error)
- func (us *UserService) ReturnSessionToPool(session *model.Session)
- func (us *UserService) RevokeAccessToken(token string) error
- func (us *UserService) RevokeAllSessions(userID string) error
- func (us *UserService) RevokeSession(session *model.Session) error
- func (us *UserService) RevokeSessionsForDeviceId(userID string, deviceID string, currentSessionId string) error
- func (us *UserService) RevokeSessionsFromAllUsers() error
- func (us *UserService) SanitizeProfile(user *model.User, asAdmin bool)
- func (us *UserService) SessionCacheLength() int
- func (us *UserService) SetSessionExpireInDays(session *model.Session, days int)
- func (us *UserService) UpdateSessionsIsGuest(userID string, isGuest bool) error
- func (us *UserService) UpdateUser(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error)
- func (us *UserService) UpdateUserNotifyProps(userID string, props map[string]string) error
Constants ¶
const ( TokenTypePasswordRecovery = "password_recovery" TokenTypeVerifyEmail = "verify_email" TokenTypeTeamInvitation = "team_invitation" TokenTypeGuestInvitation = "guest_invitation" InvitationExpiryTime = 1000 * 60 * 60 * 48 // 48 hours )
Variables ¶
var ( AcceptedDomainError = errors.New("the email provided does not belong to an accepted domain") VerifyUserError = errors.New("could not update verify email field") UserCountError = errors.New("could not get the total number of the users.") UserCreationDisabledError = errors.New("user creation is not allowed") UserStoreIsEmptyError = errors.New("could not check if the user store is empty") GetTokenError = errors.New("could not get token") GetSessionError = errors.New("could not get session") DeleteTokenError = errors.New("could not delete token") DeleteSessionError = errors.New("could not delete session") DeleteAllAccessDataError = errors.New("could not delete all access data") DefaultFontError = errors.New("could not get default font") UserInitialsError = errors.New("could not get user initials") ImageEncodingError = errors.New("could not encode image") )
Functions ¶
func CheckEmailDomain ¶
CheckEmailDomain checks that an email domain matches a list of space-delimited domains as a string.
func CheckUserDomain ¶
CheckUserDomain checks that a user's email domain matches a list of space-delimited domains as a string.
func ComparePassword ¶
func HashPassword ¶
HashPassword generates a hash using the bcrypt.GenerateFromPassword
func IsPasswordValidWithSettings ¶
func IsPasswordValidWithSettings(password string, settings *model.PasswordSettings) error
IsPasswordValidWithSettings is a utility functions that checks if the given password conforms to the password settings. It returns the error id as error value.
Types ¶
type ErrInvalidPassword ¶
type ErrInvalidPassword struct {
// contains filtered or unexported fields
}
ErrInvalidPassword indicates an error against the password settings
func NewErrInvalidPassword ¶
func NewErrInvalidPassword(id string) *ErrInvalidPassword
func (*ErrInvalidPassword) Error ¶
func (e *ErrInvalidPassword) Error() string
func (*ErrInvalidPassword) Id ¶
func (e *ErrInvalidPassword) Id() string
type ServiceConfig ¶
type ServiceConfig struct { // Mandatory fields UserStore store.UserStore SessionStore store.SessionStore OAuthStore store.OAuthStore ConfigFn func() *model.Config LicenseFn func() *model.License // Optional fields Metrics einterfaces.MetricsInterface Cluster einterfaces.ClusterInterface }
ServiceConfig is used to initialize the UserService.
type UserCreateOptions ¶
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func New ¶
func New(c ServiceConfig) (*UserService, error)
func (*UserService) ActivateMfa ¶
func (us *UserService) ActivateMfa(user *model.User, token string) error
func (*UserService) AddSessionToCache ¶
func (us *UserService) AddSessionToCache(session *model.Session)
func (*UserService) ClearAllUsersSessionCache ¶
func (us *UserService) ClearAllUsersSessionCache()
func (*UserService) ClearAllUsersSessionCacheLocal ¶
func (us *UserService) ClearAllUsersSessionCacheLocal()
func (*UserService) ClearUserSessionCache ¶
func (us *UserService) ClearUserSessionCache(userID string)
func (*UserService) ClearUserSessionCacheLocal ¶
func (us *UserService) ClearUserSessionCacheLocal(userID string)
func (*UserService) CreateSession ¶
func (*UserService) CreateUser ¶
func (us *UserService) CreateUser(user *model.User, opts UserCreateOptions) (*model.User, error)
CreateUser creates a user
func (*UserService) DeactivateAllGuests ¶
func (us *UserService) DeactivateAllGuests() ([]string, error)
func (*UserService) DeactivateMfa ¶
func (us *UserService) DeactivateMfa(user *model.User) error
func (*UserService) DemoteUserToGuest ¶
func (*UserService) ExtendSessionExpiry ¶
func (us *UserService) ExtendSessionExpiry(session *model.Session, newExpiry int64) error
func (*UserService) FileBackend ¶
func (us *UserService) FileBackend() (filestore.FileBackend, error)
func (*UserService) GenerateMfaSecret ¶
func (*UserService) GetDefaultProfileImage ¶
func (us *UserService) GetDefaultProfileImage(user *model.User) ([]byte, error)
func (*UserService) GetProfileImage ¶
func (*UserService) GetSanitizeOptions ¶
func (us *UserService) GetSanitizeOptions(asAdmin bool) map[string]bool
func (*UserService) GetSession ¶
func (us *UserService) GetSession(token string) (*model.Session, error)
func (*UserService) GetSessionByID ¶
func (us *UserService) GetSessionByID(sessionID string) (*model.Session, error)
func (*UserService) GetSessionContext ¶
func (*UserService) GetSessions ¶
func (us *UserService) GetSessions(userID string) ([]*model.Session, error)
func (*UserService) GetUserByAuth ¶
func (*UserService) GetUserByEmail ¶
func (us *UserService) GetUserByEmail(email string) (*model.User, error)
func (*UserService) GetUserByUsername ¶
func (us *UserService) GetUserByUsername(username string) (*model.User, error)
func (*UserService) GetUsers ¶
func (us *UserService) GetUsers(options *model.UserGetOptions) ([]*model.User, error)
func (*UserService) GetUsersByIds ¶
func (us *UserService) GetUsersByIds(userIDs []string, options *store.UserGetByIdsOpts) ([]*model.User, error)
func (*UserService) GetUsersByUsernames ¶
func (us *UserService) GetUsersByUsernames(usernames []string, options *model.UserGetOptions) ([]*model.User, error)
func (*UserService) GetUsersEtag ¶
func (us *UserService) GetUsersEtag(restrictionsHash string) string
func (*UserService) GetUsersInTeam ¶
func (us *UserService) GetUsersInTeam(options *model.UserGetOptions) ([]*model.User, error)
func (*UserService) GetUsersInTeamEtag ¶
func (us *UserService) GetUsersInTeamEtag(teamID string, restrictionsHash string) string
func (*UserService) GetUsersInTeamPage ¶
func (us *UserService) GetUsersInTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, error)
func (*UserService) GetUsersNotInTeam ¶
func (us *UserService) GetUsersNotInTeam(teamID string, groupConstrained bool, offset int, limit int, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)
func (*UserService) GetUsersNotInTeamEtag ¶
func (us *UserService) GetUsersNotInTeamEtag(teamID string, restrictionsHash string) string
func (*UserService) GetUsersNotInTeamPage ¶
func (*UserService) GetUsersPage ¶
func (us *UserService) GetUsersPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, error)
func (*UserService) GetUsersWithoutTeam ¶
func (us *UserService) GetUsersWithoutTeam(options *model.UserGetOptions) ([]*model.User, error)
func (*UserService) GetUsersWithoutTeamPage ¶
func (us *UserService) GetUsersWithoutTeamPage(options *model.UserGetOptions, asAdmin bool) ([]*model.User, error)
func (*UserService) InvalidateCacheForUser ¶
func (us *UserService) InvalidateCacheForUser(userID string)
func (*UserService) IsFirstUserAccount ¶
func (us *UserService) IsFirstUserAccount() bool
func (*UserService) IsUsernameTaken ¶
func (us *UserService) IsUsernameTaken(name string) bool
IsUsernameTaken checks if the username is already used by another user. Return false if the username is invalid.
func (*UserService) PromoteGuestToUser ¶
func (us *UserService) PromoteGuestToUser(user *model.User) error
func (*UserService) ReturnSessionToPool ¶
func (us *UserService) ReturnSessionToPool(session *model.Session)
func (*UserService) RevokeAccessToken ¶
func (us *UserService) RevokeAccessToken(token string) error
func (*UserService) RevokeAllSessions ¶
func (us *UserService) RevokeAllSessions(userID string) error
func (*UserService) RevokeSession ¶
func (us *UserService) RevokeSession(session *model.Session) error
func (*UserService) RevokeSessionsForDeviceId ¶
func (us *UserService) RevokeSessionsForDeviceId(userID string, deviceID string, currentSessionId string) error
func (*UserService) RevokeSessionsFromAllUsers ¶
func (us *UserService) RevokeSessionsFromAllUsers() error
func (*UserService) SanitizeProfile ¶
func (us *UserService) SanitizeProfile(user *model.User, asAdmin bool)
func (*UserService) SessionCacheLength ¶
func (us *UserService) SessionCacheLength() int
func (*UserService) SetSessionExpireInDays ¶
func (us *UserService) SetSessionExpireInDays(session *model.Session, days int)
SetSessionExpireInDays sets the session's expiry the specified number of days relative to either the session creation date or the current time, depending on the `ExtendSessionOnActivity` config setting.
func (*UserService) UpdateSessionsIsGuest ¶
func (us *UserService) UpdateSessionsIsGuest(userID string, isGuest bool) error
func (*UserService) UpdateUser ¶
func (us *UserService) UpdateUser(user *model.User, allowRoleUpdate bool) (*model.UserUpdate, error)
func (*UserService) UpdateUserNotifyProps ¶
func (us *UserService) UpdateUserNotifyProps(userID string, props map[string]string) error