user

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidInput = errors.New("invalid input")

Functions

This section is empty.

Types

type DirectoryKeyEnvelope

type DirectoryKeyEnvelope struct {
	DeviceID        string
	SenderDeviceID  string
	SenderPublicKey string
	Envelope        string
	CreatedAt       time.Time
}

type ID

type ID string

type Profile

type Profile struct {
	UserID    ID
	NameEnc   string
	UpdatedAt time.Time
}

type Repository

type Repository interface {
	Create(ctx context.Context, user User) error
	GetByID(ctx context.Context, id ID) (User, error)
	GetByUsernameHash(ctx context.Context, usernameHash string) (User, error)
	Count(ctx context.Context) (int, error)
	UpsertProfile(ctx context.Context, profile Profile) error
	ListProfiles(ctx context.Context) ([]Profile, error)
	UpsertDirectoryKeyEnvelope(ctx context.Context, env DirectoryKeyEnvelope) error
	GetDirectoryKeyEnvelope(ctx context.Context, deviceID string) (DirectoryKeyEnvelope, error)
}

type Service

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

func NewService

func NewService(repo Repository, pepper string) *Service

func (*Service) Count

func (s *Service) Count(ctx context.Context) (int, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, username string) (User, error)

func (*Service) CreateWithPassword

func (s *Service) CreateWithPassword(ctx context.Context, username, passwordHash string) (User, error)

func (*Service) CreateWithPasswordAndID

func (s *Service) CreateWithPasswordAndID(ctx context.Context, id ID, username, passwordHash string, isAdmin bool, isTrusted bool) (User, error)

func (*Service) GetByID

func (s *Service) GetByID(ctx context.Context, id ID) (User, error)

func (*Service) GetByUsername

func (s *Service) GetByUsername(ctx context.Context, username string) (User, error)

func (*Service) GetDirectoryKeyEnvelope

func (s *Service) GetDirectoryKeyEnvelope(ctx context.Context, deviceID string) (DirectoryKeyEnvelope, error)

func (*Service) ListProfiles

func (s *Service) ListProfiles(ctx context.Context) ([]Profile, error)

func (*Service) NewID

func (s *Service) NewID() ID

func (*Service) UpsertDirectoryKeyEnvelope

func (s *Service) UpsertDirectoryKeyEnvelope(ctx context.Context, env DirectoryKeyEnvelope) error

func (*Service) UpsertProfile

func (s *Service) UpsertProfile(ctx context.Context, userID ID, nameEnc string) error

type User

type User struct {
	ID           ID
	UsernameHash string
	PasswordHash string
	IsAdmin      bool
	IsTrusted    bool
	CreatedAt    time.Time
}

Jump to

Keyboard shortcuts

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