Documentation
¶
Index ¶
- Constants
- Variables
- func GetUserIDFromAPIKey(apiKey string) (string, error)
- type APIKeyClaims
- type Finder
- type FinderUpdater
- type User
- func (s *User) ActivateNewUser(ctx context.Context, input models.ActivateNewUserInput) (*models.User, error)
- func (s *User) Authenticate(ctx context.Context, username string, password string) (string, error)
- func (s *User) ChangePassword(ctx context.Context, input models.UserChangePasswordInput) error
- func (s *User) ConfirmChangeEmail(ctx context.Context, tokenID uuid.UUID) (models.UserChangeEmailStatus, error)
- func (s *User) Count(ctx context.Context) (int, error)
- func (s *User) CountEditsByStatus(ctx context.Context, userID uuid.UUID) (*models.UserEditCount, error)
- func (s *User) CountVotesByType(ctx context.Context, userID uuid.UUID) (*models.UserVoteCount, error)
- func (s *User) Create(ctx context.Context, input models.UserCreateInput) (*models.User, error)
- func (s *User) CreateSystemUsers(ctx context.Context)
- func (s *User) Delete(ctx context.Context, input models.UserDestroyInput) error
- func (s *User) FindByID(ctx context.Context, id uuid.UUID) (*models.User, error)
- func (s *User) FindByName(ctx context.Context, name string) (*models.User, error)
- func (s *User) GenerateInviteCode(ctx context.Context) (*uuid.UUID, error)
- func (s *User) GenerateInviteCodes(ctx context.Context, input *models.GenerateInviteCodeInput) ([]uuid.UUID, error)
- func (s *User) GetNotificationSubscriptions(ctx context.Context, userID uuid.UUID) ([]models.NotificationEnum, error)
- func (s *User) GetRoles(ctx context.Context, userID uuid.UUID) ([]models.RoleEnum, error)
- func (s *User) GrantInvite(ctx context.Context, input models.GrantInviteInput) (int, error)
- func (s *User) NewUser(ctx context.Context, emailAddr string, inviteKey *uuid.UUID) (*uuid.UUID, error)
- func (s *User) Query(ctx context.Context, input models.UserQueryInput) (*models.QueryUsersResultType, error)
- func (s *User) RegenerateAPIKey(ctx context.Context, userID *uuid.UUID) (string, error)
- func (s *User) RequestChangeEmail(ctx context.Context) (models.UserChangeEmailStatus, error)
- func (s *User) RescindInviteCode(ctx context.Context, inviteKeyID uuid.UUID) error
- func (s *User) ResetPassword(ctx context.Context, input models.ResetPasswordInput) error
- func (s *User) RevokeInvite(ctx context.Context, input models.RevokeInviteInput) (int, error)
- func (s *User) Update(ctx context.Context, input models.UserUpdateInput) (*models.User, error)
- func (s *User) ValidateChangeEmail(ctx context.Context, tokenID uuid.UUID, emailAddr string) (models.UserChangeEmailStatus, error)
- func (s *User) WithTxn(fn func(*queries.Queries) error) error
Constants ¶
View Source
const APIKeySubject = "APIKey"
Variables ¶
View Source
var ( ErrUserNotExist = errors.New("user not found") ErrEmptyUsername = errors.New("empty username") ErrUsernameHasWhitespace = errors.New("username has leading or trailing whitespace") ErrUsernameMatchesEmail = errors.New("username is the same as email") ErrEmptyEmail = errors.New("empty email") ErrEmailHasWhitespace = errors.New("email has leading or trailing whitespace") ErrInvalidEmail = errors.New("not a valid email address") ErrPasswordTooShort = fmt.Errorf("password length < %d", minPasswordLength) ErrPasswordTooLong = fmt.Errorf("password > %d", maxPasswordLength) ErrPasswordInsufficientUniqueChars = fmt.Errorf("password has < %d unique characters", minUniqueChars) ErrBannedPassword = errors.New("password matches a common password") ErrPasswordUsername = errors.New("password matches username") ErrPasswordEmail = errors.New("password matches email") ErrDeleteSystemUser = errors.New("system users cannot be deleted") ErrChangeModUser = errors.New("mod user cannot be modified") ErrChangeRootName = errors.New("cannot change root username") ErrChangeRootRoles = errors.New("cannot change root roles") ErrAccessDenied = errors.New("access denied") ErrCurrentPasswordIncorrect = errors.New("current password incorrect") )
View Source
var ErrInvalidActivationKey = errors.New("invalid activation key")
View Source
var ErrInvalidToken = errors.New("invalid apikey")
View Source
var ErrNoInviteTokens = errors.New("no invite tokens available")
Functions ¶
func GetUserIDFromAPIKey ¶
GetUserIDFromAPIKey validates the provided api key and returns the user ID
Types ¶
type APIKeyClaims ¶
type APIKeyClaims struct {
UserID string `json:"uid"`
jwt.RegisteredClaims
}
type FinderUpdater ¶
type User ¶
type User struct {
// contains filtered or unexported fields
}
User handles user-related operations
func (*User) ActivateNewUser ¶
func (*User) Authenticate ¶
Authenticate validates the provided username and password. If correct, it returns the id of the user.
func (*User) ChangePassword ¶
func (*User) ConfirmChangeEmail ¶
func (*User) CountEditsByStatus ¶
func (*User) CountVotesByType ¶
func (*User) CreateSystemUsers ¶
func (*User) FindByName ¶
func (*User) GenerateInviteCode ¶
func (*User) GenerateInviteCodes ¶
func (*User) GetNotificationSubscriptions ¶
func (*User) GrantInvite ¶
func (*User) NewUser ¶
func (s *User) NewUser(ctx context.Context, emailAddr string, inviteKey *uuid.UUID) (*uuid.UUID, error)
NewUser registers a new user. It returns the activation key only if email verification is not required, otherwise it returns nil.
func (*User) Query ¶
func (s *User) Query(ctx context.Context, input models.UserQueryInput) (*models.QueryUsersResultType, error)
func (*User) RegenerateAPIKey ¶
func (*User) RequestChangeEmail ¶
func (*User) RescindInviteCode ¶
func (*User) ResetPassword ¶
func (*User) RevokeInvite ¶
func (*User) ValidateChangeEmail ¶
Click to show internal directories.
Click to hide internal directories.