identity

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSlugNotFound = errors.New("slug_not_found")

ErrSlugNotFound is returned when neither the tenants/users table nor the rename history contains the requested slug.

Functions

This section is empty.

Types

type RenameHop added in v0.7.0

type RenameHop struct {
	FromSlug  string
	ToSlug    string
	RenamedAt time.Time
	RenamedBy string // empty when actor wasn't recorded (e.g. backfilled rows)
}

RenameHop is one entry in a row's rename history.

type Store

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

Store provides minimal identity lookups/mutations against profiles schema.

func NewStore

func NewStore(pg *pgxpool.Pool, schema string) *Store

func (*Store) ForwardTenantSlug added in v0.12.4

func (s *Store) ForwardTenantSlug(ctx context.Context, slug string) (string, error)

ForwardTenantSlug resolves any slug — current OR historical — to the current slug of the owning tenant. Returns ErrSlugNotFound when no row matches.

Lookup order:

  1. Direct match on tenants.slug (the typical "no rename" case).
  2. Match on tenant_renames.from_slug, joined to live tenants row, most-recent-rename wins (handles rename-back + post-hard-delete reuse).

func (*Store) ForwardUserUsername added in v0.7.0

func (s *Store) ForwardUserUsername(ctx context.Context, username string) (string, error)

ForwardUserUsername is the user-namespace equivalent of ForwardTenantSlug.

func (*Store) GetByID

func (s *Store) GetByID(ctx context.Context, id uuid.UUID) (*User, error)

func (*Store) GetEmailsByIDs

func (s *Store) GetEmailsByIDs(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]string, error)

GetEmailsByIDs returns user_id -> email.

func (*Store) GetIDByUsername

func (s *Store) GetIDByUsername(ctx context.Context, username string) (uuid.UUID, error)

func (*Store) GetUsernamesByIDs

func (s *Store) GetUsernamesByIDs(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]string, error)

GetUsernamesByIDs returns user_id -> username (empty if NULL).

func (*Store) GetUsersByIDs

func (s *Store) GetUsersByIDs(ctx context.Context, ids []uuid.UUID) (map[uuid.UUID]struct{ Username, Email string }, error)

GetUsersByIDs returns username+email pairs for given IDs.

func (*Store) ListOrgRenameHistory added in v0.7.0

func (s *Store) ListOrgRenameHistory(ctx context.Context, tenantID string) ([]RenameHop, error)

ListOrgRenameHistory returns the recorded tenant slug rename rows in chronological order. Orgs with no renames return an empty slice.

func (*Store) ListUserRenameHistory added in v0.7.0

func (s *Store) ListUserRenameHistory(ctx context.Context, userID string) ([]RenameHop, error)

ListUserRenameHistory is the user equivalent. Users with no renames return an empty slice.

func (*Store) UpdateEmail

func (s *Store) UpdateEmail(ctx context.Context, id uuid.UUID, email string) error

func (*Store) UpdateUsername

func (s *Store) UpdateUsername(ctx context.Context, id uuid.UUID, username string) error

type User

type User struct {
	ID            uuid.UUID
	Email         string
	Username      *string
	EmailVerified bool
}

Jump to

Keyboard shortcuts

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