users

package
v6.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2022 License: AGPL-3.0, Apache-2.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TokenTypePasswordRecovery = "password_recovery"
	TokenTypeVerifyEmail      = "verify_email"
	TokenTypeTeamInvitation   = "team_invitation"
	TokenTypeGuestInvitation  = "guest_invitation"
	InvitationExpiryTime      = 1000 * 60 * 60 * 48 // 48 hours
)

Variables

View Source
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

func CheckEmailDomain(email string, domains string) bool

CheckEmailDomain checks that an email domain matches a list of space-delimited domains as a string.

func CheckUserDomain

func CheckUserDomain(user *model.User, domains string) bool

CheckUserDomain checks that a user's email domain matches a list of space-delimited domains as a string.

func CheckUserPassword

func CheckUserPassword(user *model.User, password string) error

func ComparePassword

func ComparePassword(hash string, password string) error

func HashPassword

func HashPassword(password string) string

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 UserCreateOptions struct {
	Guest      bool
	FromImport bool
}

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 (us *UserService) CreateSession(session *model.Session) (*model.Session, error)

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 (us *UserService) DemoteUserToGuest(user *model.User) (*model.User, error)

func (*UserService) ExtendSessionExpiry added in v6.6.0

func (us *UserService) ExtendSessionExpiry(session *model.Session, newExpiry int64) error

func (*UserService) FileBackend

func (us *UserService) FileBackend() (filestore.FileBackend, error)

func (*UserService) GenerateMfaSecret

func (us *UserService) GenerateMfaSecret(user *model.User) (*model.MfaSecret, error)

func (*UserService) GetDefaultProfileImage

func (us *UserService) GetDefaultProfileImage(user *model.User) ([]byte, error)

func (*UserService) GetProfileImage

func (us *UserService) GetProfileImage(user *model.User) ([]byte, bool, error)

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 (us *UserService) GetSessionContext(ctx context.Context, token string) (*model.Session, error)

func (*UserService) GetSessions

func (us *UserService) GetSessions(userID string) ([]*model.Session, error)

func (*UserService) GetUser

func (us *UserService) GetUser(userID string) (*model.User, error)

func (*UserService) GetUserByAuth

func (us *UserService) GetUserByAuth(authData *string, authService string) (*model.User, error)

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 (us *UserService) GetUsersNotInTeamPage(teamID string, groupConstrained bool, page int, perPage int, asAdmin bool, viewRestrictions *model.ViewUsersRestrictions) ([]*model.User, error)

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) ReadFile

func (us *UserService) ReadFile(path string) ([]byte, 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL