user

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package user manages users and tenant membership metadata.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidUser    = errors.New("gotenancy/user: invalid user")
	ErrUserNotFound   = errors.New("gotenancy/user: user not found")
	ErrUserExists     = errors.New("gotenancy/user: user already exists")
	ErrMemberNotFound = errors.New("gotenancy/user: member not found")
	ErrMemberExists   = errors.New("gotenancy/user: member already exists")
	ErrTenantMismatch = errors.New("gotenancy/user: tenant mismatch")
)

Functions

This section is empty.

Types

type Member

type Member struct {
	TenantID types.TenantID
	UserID   string
	Roles    []string
}

Member binds a user to a tenant.

type MemoryService

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

func NewMemoryService

func NewMemoryService() *MemoryService

func (*MemoryService) AddMember

func (service *MemoryService) AddMember(ctx context.Context, member Member) error

func (*MemoryService) CreateUser

func (service *MemoryService) CreateUser(ctx context.Context, user User) error

func (*MemoryService) GetMember

func (service *MemoryService) GetMember(ctx context.Context, tenantID types.TenantID, userID string) (Member, error)

func (*MemoryService) GetUser

func (service *MemoryService) GetUser(ctx context.Context, id string) (User, error)

func (*MemoryService) ListMembers

func (service *MemoryService) ListMembers(ctx context.Context, tenantID types.TenantID) ([]Member, error)

func (*MemoryService) RemoveMember

func (service *MemoryService) RemoveMember(ctx context.Context, tenantID types.TenantID, userID string) error

type Service

type Service interface {
	CreateUser(ctx context.Context, user User) error
	GetUser(ctx context.Context, id string) (User, error)
	AddMember(ctx context.Context, member Member) error
	GetMember(ctx context.Context, tenantID types.TenantID, userID string) (Member, error)
	ListMembers(ctx context.Context, tenantID types.TenantID) ([]Member, error)
	RemoveMember(ctx context.Context, tenantID types.TenantID, userID string) error
}

type User

type User struct {
	ID    string
	Email string
	Name  string
}

User is an account that may belong to many tenants.

Jump to

Keyboard shortcuts

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