identity

package
v0.0.0-...-61c90a5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound           = errors.New("not found")
	ErrConflict           = errors.New("conflict")
	ErrBootstrapClosed    = errors.New("first-account registration is closed")
	ErrInvalidInvite      = errors.New("invalid or expired invitation")
	ErrPermissionDenied   = errors.New("permission denied")
	ErrInvalidCredentials = errors.New("invalid email or password")
)

Functions

This section is empty.

Types

type CreateUserParams

type CreateUserParams struct {
	Email        string
	Username     string
	DisplayName  string
	PasswordHash string
}

type Invite

type Invite struct {
	ID        string
	CircleID  string
	InviterID string
	Email     string
	ExpiresAt time.Time
	CreatedAt time.Time
}

type RegisterParams

type RegisterParams struct {
	Email       string
	Username    string
	DisplayName string
	Password    string
	InviteToken string
}

type Repository

type Repository interface {
	HasUsers(context.Context) (bool, error)
	BootstrapOwner(context.Context, CreateUserParams) (User, error)
	RegisterWithInvite(context.Context, []byte, CreateUserParams) (User, error)
	InviteByToken(context.Context, []byte, time.Time) (Invite, error)
	CreateFamilyInvite(context.Context, string, string, []byte, time.Time) (Invite, error)
	UserByEmail(context.Context, string) (User, error)
	CreateSession(context.Context, []byte, string, time.Time) error
	UserBySession(context.Context, []byte, time.Time) (User, error)
	DeleteSession(context.Context, []byte) error
}

type Service

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

func NewService

func NewService(repository Repository, sessionTTL time.Duration) (*Service, error)

func (*Service) CreateInvite

func (s *Service) CreateInvite(ctx context.Context, inviterID, email string) (Invite, string, error)

func (*Service) Login

func (s *Service) Login(ctx context.Context, email, password string) (User, Session, error)

func (*Service) Logout

func (s *Service) Logout(ctx context.Context, rawToken string) error

func (*Service) Register

func (s *Service) Register(ctx context.Context, params RegisterParams) (User, error)

func (*Service) RegistrationOpen

func (s *Service) RegistrationOpen(ctx context.Context) (bool, error)

func (*Service) StartSession

func (s *Service) StartSession(ctx context.Context, userID string) (Session, error)

func (*Service) UserBySession

func (s *Service) UserBySession(ctx context.Context, rawToken string) (User, error)

func (*Service) ValidateInvite

func (s *Service) ValidateInvite(ctx context.Context, rawToken string) (Invite, error)

type Session

type Session struct {
	Token     string
	ExpiresAt time.Time
}

type User

type User struct {
	ID            string
	Email         string
	Username      string
	DisplayName   string
	Bio           string
	PasswordHash  string
	PublicProfile bool
	EmailVerified bool
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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