users

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package users is the user-account domain service: registration validation, profile reads, and password changes. Admin user management also lives here. It never imports HTTP; handlers translate its errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminListFilters

type AdminListFilters struct {
	Query  *string
	Banned *bool
	Hidden *bool
	Role   *string
}

AdminListFilters narrows the admin user list.

type AdminListResult

type AdminListResult struct {
	Items []gen.ListUsersAdminRow
	Total int64
}

AdminListResult is a page of users with their team refs.

type RegisterInput

type RegisterInput struct {
	Username string
	Email    string
	Password string
}

RegisterInput is the validated registration payload.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements user-account operations over the store.

func New

func New(q *gen.Queries, sessions *auth.SessionStore, registrationOpen bool) *Service

New builds the service.

func (*Service) AdminResetPassword

func (s *Service) AdminResetPassword(ctx context.Context, targetID uuid.UUID, newPassword string) error

AdminResetPassword sets a new password and revokes the user's sessions.

func (*Service) AdminUpdate

func (s *Service) AdminUpdate(ctx context.Context, actorID, targetID uuid.UUID, banned, hidden *bool, role *string) (gen.User, error)

AdminUpdate toggles banned/hidden or changes role. Banning revokes the user's sessions. Admins cannot ban or demote themselves.

func (*Service) ChangePassword

func (s *Service) ChangePassword(ctx context.Context, userID uuid.UUID, current, newPassword, keepSessionToken string) error

ChangePassword verifies the current password and swaps in the new one, revoking every other session of the user.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id uuid.UUID) (gen.User, error)

Get returns a user by ID.

func (*Service) ListAdmin

ListAdmin returns a page of users for the admin panel.

func (*Service) Register

func (s *Service) Register(ctx context.Context, in RegisterInput) (gen.User, error)

Register validates and creates a user account.

func (*Service) RehashPassword

func (s *Service) RehashPassword(ctx context.Context, userID uuid.UUID, newHash string) error

RehashPassword persists a transparently upgraded hash (login-time rehash).

func (*Service) Solves

func (s *Service) Solves(ctx context.Context, userID uuid.UUID) ([]gen.ListUserSolvesRow, error)

Solves returns a user's personal scoring solves.

func (*Service) TeamOf

func (s *Service) TeamOf(ctx context.Context, userID uuid.UUID) (*TeamRef, error)

TeamOf returns the user's team reference, or nil when teamless.

type TeamRef

type TeamRef struct {
	ID   uuid.UUID
	Name string
	Role string // captain | member
}

TeamRef is a compact team reference with the caller's role in it.

Jump to

Keyboard shortcuts

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