service

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultTokenTTL preserves the previously-hardcoded value of 30 days.
	DefaultTokenTTL = 30 * 24 * time.Hour

	// DefaultActivationSubject is used when Options.ActivationSubject is empty.
	DefaultActivationSubject = "Confirm your account"
)

Default values applied when the corresponding Options fields are zero. Kept exported so callers building custom configurations can compose against the same defaults.

View Source
const Name = "user"

Name is the service module name.

Variables

This section is empty.

Functions

func FS

func FS(ctx context.Context) fs.FS

FS returns a layered filesystem combining theme, view, and basecoat assets.

Types

type EmailSender

type EmailSender interface {
	Send(ctx context.Context, recipient, subject, body string) error
}

EmailSender is the minimal contract the user module needs to deliver transactional mail. It deliberately mirrors the signature of the email module's Handler.Send so a *email.Handler can be passed directly without an adapter.

type Options

type Options struct {
	SigningKey string

	// TokenTTL is the lifetime for issued access JWTs. If zero,
	// DefaultTokenTTL is used.
	TokenTTL time.Duration

	// EmailActivationEnabled gates account activation behind an email
	// confirmation step. When false (the default), users are activated
	// on creation; the email may still be confirmed via a separate
	// flow added later. When true, registration leaves the user
	// pending until they exchange an activation token sent via the
	// configured EmailSender, and login is refused for pending users.
	EmailActivationEnabled bool

	// EmailSender delivers transactional mail. The email module's
	// *email.Handler satisfies this interface. When
	// EmailActivationEnabled is true and EmailSender is nil, the user
	// module fails to start so the misconfiguration is loud.
	EmailSender EmailSender

	// ActivationURLFormat is a Sprintf-style template that the user
	// module substitutes the activation token into when composing the
	// activation email. Example:
	//   "https://example.com/activate?token=%s"
	// When empty, the activation email contains the bare token and the
	// caller is expected to provide UX instructions out-of-band.
	ActivationURLFormat string

	// ActivationSubject overrides the subject line of activation
	// emails. When empty, DefaultActivationSubject is used.
	ActivationSubject string
}

Options is passed from user package scope. Every field has a defensible zero value so a bare Options{SigningKey: ...} keeps the historical behaviour. Toggles can be set explicitly to opt into newer flows.

type UserModule

type UserModule struct {
	platform.UnimplementedModule
	// contains filtered or unexported fields
}

UserModule implements a module contract.

func NewUserModule

func NewUserModule(opts Options) *UserModule

NewUserModule sets up dependencies and produces a UserModule.

func (*UserModule) Mount

func (h *UserModule) Mount(_ context.Context, r platform.Router) error

Mount registers login, logout, and register routes.

func (*UserModule) Name

func (h *UserModule) Name() string

Name returns the name of the containing package.

func (*UserModule) Start

func (h *UserModule) Start(ctx context.Context) error

Start will initialize the service to handle requests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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