Versions in this module Expand all Collapse all v0 v0.1.0 Nov 9, 2026 Changes in this version + const DefaultInviteTTL + var ContentRatings = []string + var ErrAlreadySetUp = errors.New("users: the first account already exists") + var ErrCannotChangeSelf = errors.New("users: admins can't disable, demote or delete themselves") + var ErrInviteInvalid = errors.New("users: invite unknown, used or expired") + var ErrLastAdmin = errors.New("users: the last enabled admin can't be disabled, demoted or deleted") + var ErrNotFound = errors.New("users: not found") + var ErrUsernameTaken = errors.New("users: username taken") + type Grants struct + AllSources bool + AllowedSources []string + ContentRatingCeiling string + MayAdd bool + MayDownload bool + MayManageMatches bool + func AdminGrants() Grants + func DefaultGrants() Grants + func Effective(u db.User) Grants + func GrantsOf(u db.User) Grants + func InviteGrants(inv db.Invite) (Grants, error) + func (g Grants) Validate() error + type GrantsPatch struct + AllSources *bool + AllowedSources *[]string + ContentRatingCeiling *string + MayAdd *bool + MayDownload *bool + MayManageMatches *bool + func (p *GrantsPatch) Apply(g Grants) Grants + type NewInvite struct + Grants Grants + Note string + Role string + TTL time.Duration + type NewUser struct + DisplayName string + Grants Grants + Password string + Role string + Username string + type Patch struct + Disabled *bool + DisplayName *string + Grants *GrantsPatch + Password *string + Role *string + type Service struct + func NewService(st *store.Store, a *auth.Service, log *slog.Logger) *Service + func (s *Service) AcceptInvite(ctx context.Context, token string, n NewUser, ci auth.ClientInfo) (db.User, auth.NewSession, error) + func (s *Service) CheckInvite(ctx context.Context, token string) (db.Invite, error) + func (s *Service) CompleteSetup(ctx context.Context, actor uuid.UUID) (SetupStatus, error) + func (s *Service) CreateFirstAdmin(ctx context.Context, n NewUser, ci auth.ClientInfo) (db.User, auth.NewSession, error) + func (s *Service) CreateInvite(ctx context.Context, actor uuid.UUID, n NewInvite) (db.Invite, string, error) + func (s *Service) CreateUser(ctx context.Context, actor uuid.UUID, n NewUser) (db.User, error) + func (s *Service) DeleteInvite(ctx context.Context, actor, id uuid.UUID) error + func (s *Service) DeleteUser(ctx context.Context, actor, id uuid.UUID) error + func (s *Service) GetUser(ctx context.Context, id uuid.UUID) (db.User, error) + func (s *Service) HasUsers(ctx context.Context) (bool, error) + func (s *Service) ListInvites(ctx context.Context) ([]db.Invite, error) + func (s *Service) ListUsers(ctx context.Context, after string, limit int) ([]db.User, string, error) + func (s *Service) SetupStatus(ctx context.Context) (SetupStatus, error) + func (s *Service) UpdateUser(ctx context.Context, actor, id uuid.UUID, p Patch) (db.User, error) + type SetupStatus struct + AdminCreated bool + CompletedAt *time.Time