Documentation
¶
Overview ¶
Package command provides a cron-friendly command for activity backfills.
Package command exposes go-command compatible command handlers implementing go-users business logic (lifecycle transitions, invites, role updates, etc.). Commands are wired by the service layer and can be invoked by any transport.
Index ¶
- Constants
- Variables
- type ActivityLogCommand
- type ActivityLogConfig
- type ActivityLogInput
- type AssignRoleCommand
- type AssignRoleInput
- type BulkUserImportCommand
- type BulkUserImportInput
- type BulkUserImportResult
- type BulkUserTransitionCommand
- type BulkUserTransitionInput
- type BulkUserTransitionResult
- type Command
- type Config
- type CreateRoleCommand
- type CreateRoleInput
- type DeleteRoleCommand
- type DeleteRoleInput
- type Input
- type InviteCommandConfig
- type LifecycleCommandConfig
- type PasswordResetCommandConfig
- type PasswordResetConfirmConfig
- type PasswordResetRequestConfig
- type PreferenceCommandConfig
- type PreferenceDeleteCommand
- type PreferenceDeleteInput
- type PreferenceUpsertCommand
- type PreferenceUpsertInput
- type ProfileCommandConfig
- type ProfileUpsertCommand
- type ProfileUpsertInput
- type RegistrationRequestConfig
- type TokenConsumeConfig
- type TokenValidateConfig
- type UnassignRoleCommand
- type UnassignRoleInput
- type UpdateRoleCommand
- type UpdateRoleInput
- type UserCreateCommand
- type UserCreateCommandConfig
- type UserCreateInput
- type UserInviteCommand
- type UserInviteInput
- type UserInviteResult
- type UserLifecycleTransitionCommand
- type UserLifecycleTransitionInput
- type UserLifecycleTransitionResult
- type UserPasswordResetCommand
- type UserPasswordResetConfirmCommand
- type UserPasswordResetConfirmInput
- type UserPasswordResetConfirmResult
- type UserPasswordResetInput
- type UserPasswordResetRequestCommand
- type UserPasswordResetRequestInput
- type UserPasswordResetRequestResult
- type UserPasswordResetResult
- type UserRegistrationRequestCommand
- type UserRegistrationRequestInput
- type UserRegistrationRequestResult
- type UserTokenConsumeCommand
- type UserTokenConsumeInput
- type UserTokenConsumeResult
- type UserTokenValidateCommand
- type UserTokenValidateInput
- type UserTokenValidateResult
- type UserUpdateCommand
- type UserUpdateCommandConfig
- type UserUpdateInput
Constants ¶
const ( // DefaultSchedule is the fallback cron expression when none is configured. DefaultSchedule = "0 * * * *" // DefaultBatchSize matches the repository default for enrichment selection. DefaultBatchSize = 200 // MaxBatchSize caps the batch size to protect the resolver pipeline. MaxBatchSize = 1000 )
const ( SecureLinkActionInvite = "invite" SecureLinkActionRegister = "register" SecureLinkActionPasswordReset = "password_reset" )
const ( SecureLinkRouteInviteAccept = "invite_accept" SecureLinkRouteRegister = "register" SecureLinkRoutePasswordReset = "password_reset" )
Variables ¶
var ( // ErrMissingEnrichmentQuery indicates the enrichment query dependency is missing. ErrMissingEnrichmentQuery = errors.New("go-users: missing activity enrichment query") // ErrMissingEnrichmentStore indicates the enrichment store dependency is missing. ErrMissingEnrichmentStore = errors.New("go-users: missing activity enrichment store") // ErrMissingCommand indicates the command instance was not provided. ErrMissingCommand = errors.New("go-users: activity enrichment command required") )
var ( // ErrLifecycleUserIDRequired indicates the transition command lacks a user ID. ErrLifecycleUserIDRequired = errors.New("go-users: lifecycle transition requires user id") // ErrLifecycleTargetRequired indicates the desired lifecycle state is missing. ErrLifecycleTargetRequired = errors.New("go-users: lifecycle transition requires target state") // ErrActorRequired indicates an actor reference was not supplied. ErrActorRequired = types.ErrActorRequired // ErrUserRequired indicates a user payload was not supplied. ErrUserRequired = errors.New("go-users: user payload required") // ErrUserNotFound indicates the requested user was not found. ErrUserNotFound = errors.New("go-users: user not found") // ErrUserEmailRequired indicates a user email address was missing. ErrUserEmailRequired = errors.New("go-users: user email required") // ErrInviteEmailRequired occurs when an invite omits the email address. ErrInviteEmailRequired = errors.New("go-users: invite requires email") // ErrInviteDisabled indicates the invite flow is disabled via feature gate. ErrInviteDisabled = errors.New("go-users: invite disabled") // ErrPasswordHashRequired occurs when a password reset omits the hashed password. ErrPasswordHashRequired = errors.New("go-users: password reset requires password hash") // ErrPasswordResetDisabled indicates password reset is disabled via feature gate. ErrPasswordResetDisabled = errors.New("go-users: password reset disabled") // ErrUserIDsRequired occurs when bulk handlers are invoked without targets. ErrUserIDsRequired = errors.New("go-users: user ids required") // ErrUsersRequired occurs when bulk user import lacks users. ErrUsersRequired = errors.New("go-users: users required") // ErrRoleNameRequired occurs when a role command omits the role name. ErrRoleNameRequired = errors.New("go-users: role name required") // ErrRoleIDRequired signals the role ID was missing. ErrRoleIDRequired = errors.New("go-users: role id required") // ErrUserIDRequired occurs when assignment commands omit the user. ErrUserIDRequired = types.ErrUserIDRequired // ErrActivityVerbRequired indicates an activity log entry is missing a verb. ErrActivityVerbRequired = errors.New("go-users: activity verb required") // ErrPreferenceKeyRequired indicates the preference key was missing. ErrPreferenceKeyRequired = errors.New("go-users: preference key required") // ErrPreferenceValueRequired indicates the preference value payload was missing. ErrPreferenceValueRequired = errors.New("go-users: preference value required") // ErrTokenRequired indicates a securelink token was missing. ErrTokenRequired = errors.New("go-users: token required") // ErrTokenTypeRequired indicates a token type was missing. ErrTokenTypeRequired = errors.New("go-users: token type required") // ErrTokenJTIRequired indicates the token payload lacked a JTI. ErrTokenJTIRequired = errors.New("go-users: token jti required") // ErrTokenNotFound indicates the token registry has no matching record. ErrTokenNotFound = errors.New("go-users: token not found") // ErrTokenExpired indicates the token has expired. ErrTokenExpired = errors.New("go-users: token expired") // ErrTokenAlreadyUsed indicates the token has already been consumed. ErrTokenAlreadyUsed = errors.New("go-users: token already used") // ErrTokenUserMismatch indicates the token user id mismatch. ErrTokenUserMismatch = errors.New("go-users: token user mismatch") // ErrResetIdentifierRequired indicates a reset identifier was missing. ErrResetIdentifierRequired = errors.New("go-users: password reset requires identifier") // ErrResetCommandRequired indicates the reset command dependency is missing. ErrResetCommandRequired = errors.New("go-users: password reset command required") // ErrSignupDisabled indicates self-registration is disabled via feature gate. ErrSignupDisabled = errors.New("go-users: signup disabled") )
Functions ¶
This section is empty.
Types ¶
type ActivityLogCommand ¶
type ActivityLogCommand struct {
// contains filtered or unexported fields
}
ActivityLogCommand logs arbitrary activity records.
func NewActivityLogCommand ¶
func NewActivityLogCommand(cfg ActivityLogConfig) *ActivityLogCommand
NewActivityLogCommand constructs the logging command handler.
func (*ActivityLogCommand) Execute ¶
func (c *ActivityLogCommand) Execute(ctx context.Context, input ActivityLogInput) error
Execute validates and persists the supplied record.
type ActivityLogConfig ¶
ActivityLogConfig wires dependencies for the log command.
type ActivityLogInput ¶
type ActivityLogInput struct {
Record types.ActivityRecord
}
ActivityLogInput wraps a record to persist through the ActivitySink.
func (ActivityLogInput) Type ¶
func (ActivityLogInput) Type() string
Type implements gocommand.Message.
func (ActivityLogInput) Validate ¶
func (input ActivityLogInput) Validate() error
Validate implements gocommand.Message.
type AssignRoleCommand ¶
type AssignRoleCommand struct {
// contains filtered or unexported fields
}
AssignRoleCommand wraps registry assignments.
func NewAssignRoleCommand ¶
func NewAssignRoleCommand(registry types.RoleRegistry, guard scope.Guard) *AssignRoleCommand
NewAssignRoleCommand constructs the handler.
func (*AssignRoleCommand) Execute ¶
func (c *AssignRoleCommand) Execute(ctx context.Context, input AssignRoleInput) error
Execute assigns the requested role.
type AssignRoleInput ¶
type AssignRoleInput struct {
UserID uuid.UUID
RoleID uuid.UUID
Scope types.ScopeFilter
Actor types.ActorRef
}
AssignRoleInput assigns a role to a user.
func (AssignRoleInput) Type ¶
func (AssignRoleInput) Type() string
Type implements gocommand.Message.
func (AssignRoleInput) Validate ¶
func (input AssignRoleInput) Validate() error
Validate implements gocommand.Message.
type BulkUserImportCommand ¶ added in v0.7.0
type BulkUserImportCommand struct {
// contains filtered or unexported fields
}
BulkUserImportCommand imports users in bulk, reusing the create command.
func NewBulkUserImportCommand ¶ added in v0.7.0
func NewBulkUserImportCommand(create *UserCreateCommand) *BulkUserImportCommand
NewBulkUserImportCommand constructs the bulk import handler.
func (*BulkUserImportCommand) Execute ¶ added in v0.7.0
func (c *BulkUserImportCommand) Execute(ctx context.Context, input BulkUserImportInput) error
Execute imports each user sequentially, recording per-record results.
type BulkUserImportInput ¶ added in v0.7.0
type BulkUserImportInput struct {
Users []*types.AuthUser
Actor types.ActorRef
Scope types.ScopeFilter
DefaultStatus types.LifecycleState
ContinueOnError bool
DryRun bool
Results *[]BulkUserImportResult
}
BulkUserImportInput applies user creation in bulk without file parsing.
func (BulkUserImportInput) Type ¶ added in v0.7.0
func (BulkUserImportInput) Type() string
Type implements gocommand.Message.
func (BulkUserImportInput) Validate ¶ added in v0.7.0
func (input BulkUserImportInput) Validate() error
Validate implements gocommand.Message.
type BulkUserImportResult ¶ added in v0.7.0
type BulkUserImportResult struct {
Index int
UserID uuid.UUID
Email string
Status types.LifecycleState
Err error
}
BulkUserImportResult captures the outcome for a single record.
type BulkUserTransitionCommand ¶
type BulkUserTransitionCommand struct {
// contains filtered or unexported fields
}
BulkUserTransitionCommand iterates through the supplied user IDs, reusing the single-user lifecycle command to enforce policies uniformly.
func NewBulkUserTransitionCommand ¶
func NewBulkUserTransitionCommand(lifecycle *UserLifecycleTransitionCommand) *BulkUserTransitionCommand
NewBulkUserTransitionCommand constructs the bulk handler.
func (*BulkUserTransitionCommand) Execute ¶
func (c *BulkUserTransitionCommand) Execute(ctx context.Context, input BulkUserTransitionInput) error
Execute transitions each user sequentially. Errors are aggregated.
type BulkUserTransitionInput ¶
type BulkUserTransitionInput struct {
UserIDs []uuid.UUID
Target types.LifecycleState
Actor types.ActorRef
Reason string
Metadata map[string]any
Scope types.ScopeFilter
StopOnError bool
Results *[]BulkUserTransitionResult
}
BulkUserTransitionInput applies the same lifecycle change to multiple users.
func (BulkUserTransitionInput) Type ¶
func (BulkUserTransitionInput) Type() string
Type implements gocommand.Message.
func (BulkUserTransitionInput) Validate ¶
func (input BulkUserTransitionInput) Validate() error
Validate implements gocommand.Message.
type BulkUserTransitionResult ¶
BulkUserTransitionResult captures the outcome for a single user.
type Command ¶ added in v0.14.0
type Command struct {
// contains filtered or unexported fields
}
Command schedules and executes activity enrichment backfills.
func New ¶ added in v0.14.0
New constructs an activity enrichment command with the supplied configuration.
func (*Command) CronHandler ¶ added in v0.14.0
CronHandler implements gocommand.CronCommand.
func (*Command) CronOptions ¶ added in v0.14.0
func (c *Command) CronOptions() gocommand.HandlerConfig
CronOptions implements gocommand.CronCommand.
type Config ¶ added in v0.14.0
type Config struct {
Schedule string
BatchSize int
EnrichedAtCutoff time.Duration
// Scope defaults scheduled runs; zero scope means global backfill.
Scope types.ScopeFilter
ActivityRepository types.ActivityRepository
EnrichmentQuery activity.ActivityEnrichmentQuery
EnrichmentStore activity.ActivityEnrichmentStore
Enricher activity.ActivityEnricher
ActorResolver activity.ActorResolver
ObjectResolver activity.ObjectResolver
Clock types.Clock
Logger types.Logger
}
Config wires the activity enrichment command dependencies and defaults.
type CreateRoleCommand ¶
type CreateRoleCommand struct {
// contains filtered or unexported fields
}
CreateRoleCommand invokes the injected role registry.
func NewCreateRoleCommand ¶
func NewCreateRoleCommand(registry types.RoleRegistry, guard scope.Guard) *CreateRoleCommand
NewCreateRoleCommand wires a role creation handler.
func (*CreateRoleCommand) Execute ¶
func (c *CreateRoleCommand) Execute(ctx context.Context, input CreateRoleInput) error
Execute validates and forwards the creation payload to the registry.
type CreateRoleInput ¶
type CreateRoleInput struct {
Name string
Order int
Description string
RoleKey string
Permissions []string
Metadata map[string]any
IsSystem bool
Scope types.ScopeFilter
Actor types.ActorRef
Result *types.RoleDefinition
}
CreateRoleInput carries data for creating custom roles.
func (CreateRoleInput) Type ¶
func (CreateRoleInput) Type() string
Type implements gocommand.Message.
func (CreateRoleInput) Validate ¶
func (input CreateRoleInput) Validate() error
Validate implements gocommand.Message.
type DeleteRoleCommand ¶
type DeleteRoleCommand struct {
// contains filtered or unexported fields
}
DeleteRoleCommand deletes roles through the registry.
func NewDeleteRoleCommand ¶
func NewDeleteRoleCommand(registry types.RoleRegistry, guard scope.Guard) *DeleteRoleCommand
NewDeleteRoleCommand constructs the handler.
func (*DeleteRoleCommand) Execute ¶
func (c *DeleteRoleCommand) Execute(ctx context.Context, input DeleteRoleInput) error
Execute deletes the requested role after validation.
type DeleteRoleInput ¶
DeleteRoleInput removes a custom role.
func (DeleteRoleInput) Type ¶
func (DeleteRoleInput) Type() string
Type implements gocommand.Message.
func (DeleteRoleInput) Validate ¶
func (input DeleteRoleInput) Validate() error
Validate implements gocommand.Message.
type Input ¶ added in v0.14.0
type Input struct {
// Scope overrides the configured scope for this run.
Scope types.ScopeFilter
BatchSize int
EnrichedBefore *time.Time
}
Input describes a single enrichment run.
type InviteCommandConfig ¶
type InviteCommandConfig struct {
Repository types.AuthRepository
TokenRepository types.UserTokenRepository
SecureLinks types.SecureLinkManager
Clock types.Clock
IDGen types.IDGenerator
Activity types.ActivitySink
Hooks types.Hooks
Logger types.Logger
TokenTTL time.Duration
ScopeGuard scope.Guard
FeatureGate featuregate.FeatureGate
Route string
}
InviteCommandConfig holds dependencies for the invite flow.
type LifecycleCommandConfig ¶
type LifecycleCommandConfig struct {
Repository types.AuthRepository
Policy types.TransitionPolicy
Clock types.Clock
Logger types.Logger
Hooks types.Hooks
Activity types.ActivitySink
ScopeGuard scope.Guard
}
LifecycleCommandConfig configures the lifecycle command handler.
type PasswordResetCommandConfig ¶
type PasswordResetCommandConfig struct {
Repository types.AuthRepository
Clock types.Clock
Activity types.ActivitySink
Hooks types.Hooks
Logger types.Logger
ScopeGuard scope.Guard
}
PasswordResetCommandConfig wires the reset handler.
type PasswordResetConfirmConfig ¶ added in v0.11.0
type PasswordResetConfirmConfig struct {
ResetRepository types.PasswordResetRepository
SecureLinks types.SecureLinkManager
ResetCommand *UserPasswordResetCommand
Clock types.Clock
ScopeEnforcer types.ScopeEnforcer
Logger types.Logger
}
PasswordResetConfirmConfig holds dependencies for reset confirmation.
type PasswordResetRequestConfig ¶ added in v0.11.0
type PasswordResetRequestConfig struct {
Repository types.AuthRepository
ResetRepository types.PasswordResetRepository
SecureLinks types.SecureLinkManager
Clock types.Clock
IDGen types.IDGenerator
Activity types.ActivitySink
Hooks types.Hooks
Logger types.Logger
TokenTTL time.Duration
FeatureGate featuregate.FeatureGate
Route string
}
PasswordResetRequestConfig holds dependencies for reset issuance.
type PreferenceCommandConfig ¶
type PreferenceCommandConfig struct {
Repository types.PreferenceRepository
Hooks types.Hooks
Clock types.Clock
ScopeGuard scope.Guard
}
PreferenceCommandConfig wires dependencies for preference commands.
type PreferenceDeleteCommand ¶
type PreferenceDeleteCommand struct {
// contains filtered or unexported fields
}
PreferenceDeleteCommand removes a scoped preference entry.
func NewPreferenceDeleteCommand ¶
func NewPreferenceDeleteCommand(cfg PreferenceCommandConfig) *PreferenceDeleteCommand
NewPreferenceDeleteCommand constructs the delete handler.
func (*PreferenceDeleteCommand) Execute ¶
func (c *PreferenceDeleteCommand) Execute(ctx context.Context, input PreferenceDeleteInput) error
Execute removes the preference entry for the supplied key.
type PreferenceDeleteInput ¶
type PreferenceDeleteInput struct {
UserID uuid.UUID
Scope types.ScopeFilter
Level types.PreferenceLevel
Key string
Actor types.ActorRef
}
PreferenceDeleteInput captures the delete payload.
func (PreferenceDeleteInput) Type ¶
func (PreferenceDeleteInput) Type() string
Type implements gocommand.Message.
func (PreferenceDeleteInput) Validate ¶
func (input PreferenceDeleteInput) Validate() error
Validate implements gocommand.Message.
type PreferenceUpsertCommand ¶
type PreferenceUpsertCommand struct {
// contains filtered or unexported fields
}
PreferenceUpsertCommand upserts a scoped preference record.
func NewPreferenceUpsertCommand ¶
func NewPreferenceUpsertCommand(cfg PreferenceCommandConfig) *PreferenceUpsertCommand
NewPreferenceUpsertCommand constructs the handler.
func (*PreferenceUpsertCommand) Execute ¶
func (c *PreferenceUpsertCommand) Execute(ctx context.Context, input PreferenceUpsertInput) error
Execute validates and persists the preference payload.
type PreferenceUpsertInput ¶
type PreferenceUpsertInput struct {
UserID uuid.UUID
Scope types.ScopeFilter
Level types.PreferenceLevel
Key string
Value map[string]any
Actor types.ActorRef
Result *types.PreferenceRecord
}
PreferenceUpsertInput captures a preference mutation payload.
func (PreferenceUpsertInput) Type ¶
func (PreferenceUpsertInput) Type() string
Type implements gocommand.Message.
func (PreferenceUpsertInput) Validate ¶
func (input PreferenceUpsertInput) Validate() error
Validate implements gocommand.Message.
type ProfileCommandConfig ¶
type ProfileCommandConfig struct {
Repository types.ProfileRepository
Hooks types.Hooks
Clock types.Clock
ScopeGuard scope.Guard
}
ProfileCommandConfig wires dependencies for profile commands.
type ProfileUpsertCommand ¶
type ProfileUpsertCommand struct {
// contains filtered or unexported fields
}
ProfileUpsertCommand applies profile patches for a user.
func NewProfileUpsertCommand ¶
func NewProfileUpsertCommand(cfg ProfileCommandConfig) *ProfileUpsertCommand
NewProfileUpsertCommand constructs the profile command handler.
func (*ProfileUpsertCommand) Execute ¶
func (c *ProfileUpsertCommand) Execute(ctx context.Context, input ProfileUpsertInput) error
Execute applies the supplied patch creating the profile when necessary.
type ProfileUpsertInput ¶
type ProfileUpsertInput struct {
UserID uuid.UUID
Patch types.ProfilePatch
Scope types.ScopeFilter
Actor types.ActorRef
Result *types.UserProfile
}
ProfileUpsertInput captures a profile patch request.
func (ProfileUpsertInput) Type ¶
func (ProfileUpsertInput) Type() string
Type implements gocommand.Message.
func (ProfileUpsertInput) Validate ¶
func (input ProfileUpsertInput) Validate() error
Validate implements gocommand.Message.
type RegistrationRequestConfig ¶ added in v0.11.0
type RegistrationRequestConfig struct {
Repository types.AuthRepository
TokenRepository types.UserTokenRepository
SecureLinks types.SecureLinkManager
Clock types.Clock
IDGen types.IDGenerator
Activity types.ActivitySink
Hooks types.Hooks
Logger types.Logger
TokenTTL time.Duration
ScopeGuard scope.Guard
FeatureGate featuregate.FeatureGate
Route string
}
RegistrationRequestConfig holds dependencies for the registration flow.
type TokenConsumeConfig ¶ added in v0.11.0
type TokenConsumeConfig struct {
TokenRepository types.UserTokenRepository
SecureLinks types.SecureLinkManager
Clock types.Clock
ScopeEnforcer types.ScopeEnforcer
Activity types.ActivitySink
Hooks types.Hooks
}
TokenConsumeConfig holds dependencies for consumption.
type TokenValidateConfig ¶ added in v0.11.0
type TokenValidateConfig struct {
TokenRepository types.UserTokenRepository
SecureLinks types.SecureLinkManager
Clock types.Clock
ScopeEnforcer types.ScopeEnforcer
}
TokenValidateConfig holds dependencies for validation.
type UnassignRoleCommand ¶
type UnassignRoleCommand struct {
// contains filtered or unexported fields
}
UnassignRoleCommand removes assignments.
func NewUnassignRoleCommand ¶
func NewUnassignRoleCommand(registry types.RoleRegistry, guard scope.Guard) *UnassignRoleCommand
NewUnassignRoleCommand constructs the handler.
func (*UnassignRoleCommand) Execute ¶
func (c *UnassignRoleCommand) Execute(ctx context.Context, input UnassignRoleInput) error
Execute removes the given assignment.
type UnassignRoleInput ¶
type UnassignRoleInput struct {
UserID uuid.UUID
RoleID uuid.UUID
Scope types.ScopeFilter
Actor types.ActorRef
}
UnassignRoleInput removes a role assignment.
func (UnassignRoleInput) Type ¶
func (UnassignRoleInput) Type() string
Type implements gocommand.Message.
func (UnassignRoleInput) Validate ¶
func (input UnassignRoleInput) Validate() error
Validate implements gocommand.Message.
type UpdateRoleCommand ¶
type UpdateRoleCommand struct {
// contains filtered or unexported fields
}
UpdateRoleCommand updates custom roles.
func NewUpdateRoleCommand ¶
func NewUpdateRoleCommand(registry types.RoleRegistry, guard scope.Guard) *UpdateRoleCommand
NewUpdateRoleCommand constructs the command handler.
func (*UpdateRoleCommand) Execute ¶
func (c *UpdateRoleCommand) Execute(ctx context.Context, input UpdateRoleInput) error
Execute forwards the update payload to the registry.
type UpdateRoleInput ¶
type UpdateRoleInput struct {
RoleID uuid.UUID
Name string
Order int
Description string
RoleKey string
Permissions []string
Metadata map[string]any
IsSystem bool
Scope types.ScopeFilter
Actor types.ActorRef
Result *types.RoleDefinition
}
UpdateRoleInput captures mutable role fields.
func (UpdateRoleInput) Type ¶
func (UpdateRoleInput) Type() string
Type implements gocommand.Message.
func (UpdateRoleInput) Validate ¶
func (input UpdateRoleInput) Validate() error
Validate implements gocommand.Message.
type UserCreateCommand ¶ added in v0.6.0
type UserCreateCommand struct {
// contains filtered or unexported fields
}
UserCreateCommand creates active users directly.
func NewUserCreateCommand ¶ added in v0.6.0
func NewUserCreateCommand(cfg UserCreateCommandConfig) *UserCreateCommand
NewUserCreateCommand constructs the create handler.
func (*UserCreateCommand) Execute ¶ added in v0.6.0
func (c *UserCreateCommand) Execute(ctx context.Context, input UserCreateInput) error
Execute creates the user record and logs audit metadata.
type UserCreateCommandConfig ¶ added in v0.6.0
type UserCreateCommandConfig struct {
Repository types.AuthRepository
Clock types.Clock
Activity types.ActivitySink
Hooks types.Hooks
Logger types.Logger
ScopeGuard scope.Guard
}
UserCreateCommandConfig wires dependencies for the create command.
type UserCreateInput ¶ added in v0.6.0
type UserCreateInput struct {
User *types.AuthUser
Status types.LifecycleState
Actor types.ActorRef
Scope types.ScopeFilter
Result *types.AuthUser
}
UserCreateInput captures the payload for direct user creation.
func (UserCreateInput) Type ¶ added in v0.6.0
func (UserCreateInput) Type() string
Type implements gocommand.Message.
func (UserCreateInput) Validate ¶ added in v0.6.0
func (input UserCreateInput) Validate() error
Validate implements gocommand.Message.
type UserInviteCommand ¶
type UserInviteCommand struct {
// contains filtered or unexported fields
}
UserInviteCommand creates pending users and records invite metadata.
func NewUserInviteCommand ¶
func NewUserInviteCommand(cfg InviteCommandConfig) *UserInviteCommand
NewUserInviteCommand constructs the invite handler.
func (*UserInviteCommand) Execute ¶
func (c *UserInviteCommand) Execute(ctx context.Context, input UserInviteInput) error
Execute creates the pending user record and registers invite metadata.
type UserInviteInput ¶
type UserInviteInput struct {
Email string
Username string
FirstName string
LastName string
Role string
Metadata map[string]any
Actor types.ActorRef
Scope types.ScopeFilter
Result *UserInviteResult
}
UserInviteInput carries the data required to invite a new user.
func (UserInviteInput) Type ¶
func (UserInviteInput) Type() string
Type implements gocommand.Message.
func (UserInviteInput) Validate ¶
func (input UserInviteInput) Validate() error
Validate implements gocommand.Message.
type UserInviteResult ¶
UserInviteResult exposes the creation output and invite token details.
type UserLifecycleTransitionCommand ¶
type UserLifecycleTransitionCommand struct {
// contains filtered or unexported fields
}
UserLifecycleTransitionCommand implements go-command.Commander, enforcing the configured transition policy and logging hooks/audits.
func NewUserLifecycleTransitionCommand ¶
func NewUserLifecycleTransitionCommand(cfg LifecycleCommandConfig) *UserLifecycleTransitionCommand
NewUserLifecycleTransitionCommand wires the lifecycle handler.
func (*UserLifecycleTransitionCommand) Execute ¶
func (c *UserLifecycleTransitionCommand) Execute(ctx context.Context, input UserLifecycleTransitionInput) error
Execute performs the lifecycle transition against the upstream repository.
type UserLifecycleTransitionInput ¶
type UserLifecycleTransitionInput struct {
UserID uuid.UUID
Target types.LifecycleState
Actor types.ActorRef
Reason string
Metadata map[string]any
Scope types.ScopeFilter
Result *UserLifecycleTransitionResult
}
UserLifecycleTransitionInput describes the lifecycle mutation request.
func (UserLifecycleTransitionInput) Describe ¶
func (UserLifecycleTransitionInput) Describe() string
Describe returns a human readable description of the command for debugging.
func (UserLifecycleTransitionInput) Type ¶
func (UserLifecycleTransitionInput) Type() string
Type implements gocommand.Message.
func (UserLifecycleTransitionInput) Validate ¶
func (input UserLifecycleTransitionInput) Validate() error
Validate implements gocommand.Message.
type UserLifecycleTransitionResult ¶
UserLifecycleTransitionResult carries the updated auth user.
type UserPasswordResetCommand ¶
type UserPasswordResetCommand struct {
// contains filtered or unexported fields
}
UserPasswordResetCommand wraps the AuthRepository password reset helper.
func NewUserPasswordResetCommand ¶
func NewUserPasswordResetCommand(cfg PasswordResetCommandConfig) *UserPasswordResetCommand
NewUserPasswordResetCommand builds the handler.
func (*UserPasswordResetCommand) Execute ¶
func (c *UserPasswordResetCommand) Execute(ctx context.Context, input UserPasswordResetInput) error
Execute resets the user's password hash and logs audit metadata.
type UserPasswordResetConfirmCommand ¶ added in v0.11.0
type UserPasswordResetConfirmCommand struct {
// contains filtered or unexported fields
}
UserPasswordResetConfirmCommand validates tokens and applies password resets.
func NewUserPasswordResetConfirmCommand ¶ added in v0.11.0
func NewUserPasswordResetConfirmCommand(cfg PasswordResetConfirmConfig) *UserPasswordResetConfirmCommand
NewUserPasswordResetConfirmCommand constructs the confirmation handler.
func (*UserPasswordResetConfirmCommand) Execute ¶ added in v0.11.0
func (c *UserPasswordResetConfirmCommand) Execute(ctx context.Context, input UserPasswordResetConfirmInput) error
Execute validates the securelink token, consumes it, and applies the reset.
type UserPasswordResetConfirmInput ¶ added in v0.11.0
type UserPasswordResetConfirmInput struct {
Token string
NewPasswordHash string
Scope types.ScopeFilter
Result *UserPasswordResetConfirmResult
}
UserPasswordResetConfirmInput validates and consumes a reset token.
func (UserPasswordResetConfirmInput) Type ¶ added in v0.11.0
func (UserPasswordResetConfirmInput) Type() string
Type implements gocommand.Message.
func (UserPasswordResetConfirmInput) Validate ¶ added in v0.11.0
func (input UserPasswordResetConfirmInput) Validate() error
Validate implements gocommand.Message.
type UserPasswordResetConfirmResult ¶ added in v0.11.0
UserPasswordResetConfirmResult exposes the reset user.
type UserPasswordResetInput ¶
type UserPasswordResetInput struct {
UserID uuid.UUID
NewPasswordHash string
TokenJTI string
TokenExpiresAt time.Time
Actor types.ActorRef
Scope types.ScopeFilter
Result *UserPasswordResetResult
}
UserPasswordResetInput resets a user's password hash.
func (UserPasswordResetInput) Type ¶
func (UserPasswordResetInput) Type() string
Type implements gocommand.Message.
func (UserPasswordResetInput) Validate ¶
func (input UserPasswordResetInput) Validate() error
Validate implements gocommand.Message.
type UserPasswordResetRequestCommand ¶ added in v0.11.0
type UserPasswordResetRequestCommand struct {
// contains filtered or unexported fields
}
UserPasswordResetRequestCommand issues securelink reset tokens and persists lifecycle data.
func NewUserPasswordResetRequestCommand ¶ added in v0.11.0
func NewUserPasswordResetRequestCommand(cfg PasswordResetRequestConfig) *UserPasswordResetRequestCommand
NewUserPasswordResetRequestCommand constructs the request handler.
func (*UserPasswordResetRequestCommand) Execute ¶ added in v0.11.0
func (c *UserPasswordResetRequestCommand) Execute(ctx context.Context, input UserPasswordResetRequestInput) error
Execute issues a password reset token and records lifecycle metadata.
type UserPasswordResetRequestInput ¶ added in v0.11.0
type UserPasswordResetRequestInput struct {
Identifier string
UserID uuid.UUID
Actor types.ActorRef
Scope types.ScopeFilter
Metadata map[string]any
Result *UserPasswordResetRequestResult
}
UserPasswordResetRequestInput issues a password reset securelink token.
func (UserPasswordResetRequestInput) Type ¶ added in v0.11.0
func (UserPasswordResetRequestInput) Type() string
Type implements gocommand.Message.
func (UserPasswordResetRequestInput) Validate ¶ added in v0.11.0
func (input UserPasswordResetRequestInput) Validate() error
Validate implements gocommand.Message.
type UserPasswordResetRequestResult ¶ added in v0.11.0
type UserPasswordResetRequestResult struct {
User *types.AuthUser
Token string
ExpiresAt time.Time
}
UserPasswordResetRequestResult exposes the created token details.
type UserPasswordResetResult ¶
UserPasswordResetResult surfaces auditing metadata.
type UserRegistrationRequestCommand ¶ added in v0.11.0
type UserRegistrationRequestCommand struct {
// contains filtered or unexported fields
}
UserRegistrationRequestCommand creates pending users and records registration metadata.
func NewUserRegistrationRequestCommand ¶ added in v0.11.0
func NewUserRegistrationRequestCommand(cfg RegistrationRequestConfig) *UserRegistrationRequestCommand
NewUserRegistrationRequestCommand constructs the registration handler.
func (*UserRegistrationRequestCommand) Execute ¶ added in v0.11.0
func (c *UserRegistrationRequestCommand) Execute(ctx context.Context, input UserRegistrationRequestInput) error
Execute creates the pending user record and registers registration metadata.
type UserRegistrationRequestInput ¶ added in v0.11.0
type UserRegistrationRequestInput struct {
Email string
Username string
FirstName string
LastName string
Role string
Metadata map[string]any
Actor types.ActorRef
Scope types.ScopeFilter
Result *UserRegistrationRequestResult
}
UserRegistrationRequestInput carries the data required to request self-registration.
func (UserRegistrationRequestInput) Type ¶ added in v0.11.0
func (UserRegistrationRequestInput) Type() string
Type implements gocommand.Message.
func (UserRegistrationRequestInput) Validate ¶ added in v0.11.0
func (input UserRegistrationRequestInput) Validate() error
Validate implements gocommand.Message.
type UserRegistrationRequestResult ¶ added in v0.11.0
UserRegistrationRequestResult exposes the creation output and registration token details.
type UserTokenConsumeCommand ¶ added in v0.11.0
type UserTokenConsumeCommand struct {
// contains filtered or unexported fields
}
UserTokenConsumeCommand validates tokens and marks them consumed.
func NewUserTokenConsumeCommand ¶ added in v0.11.0
func NewUserTokenConsumeCommand(cfg TokenConsumeConfig) *UserTokenConsumeCommand
NewUserTokenConsumeCommand constructs the consumption handler.
func (*UserTokenConsumeCommand) Execute ¶ added in v0.11.0
func (c *UserTokenConsumeCommand) Execute(ctx context.Context, input UserTokenConsumeInput) error
Execute validates the token, records consumption, and logs activity.
type UserTokenConsumeInput ¶ added in v0.11.0
type UserTokenConsumeInput struct {
Token string
TokenType types.UserTokenType
Scope types.ScopeFilter
Result *UserTokenConsumeResult
}
UserTokenConsumeInput validates and consumes an onboarding token.
func (UserTokenConsumeInput) Type ¶ added in v0.11.0
func (UserTokenConsumeInput) Type() string
Type implements gocommand.Message.
func (UserTokenConsumeInput) Validate ¶ added in v0.11.0
func (input UserTokenConsumeInput) Validate() error
Validate implements gocommand.Message.
type UserTokenConsumeResult ¶ added in v0.11.0
type UserTokenConsumeResult struct {
Token *types.UserToken
Payload types.SecureLinkPayload
}
UserTokenConsumeResult exposes the consumed token metadata.
type UserTokenValidateCommand ¶ added in v0.11.0
type UserTokenValidateCommand struct {
// contains filtered or unexported fields
}
UserTokenValidateCommand verifies securelink tokens against stored metadata.
func NewUserTokenValidateCommand ¶ added in v0.11.0
func NewUserTokenValidateCommand(cfg TokenValidateConfig) *UserTokenValidateCommand
NewUserTokenValidateCommand constructs the validation handler.
func (*UserTokenValidateCommand) Execute ¶ added in v0.11.0
func (c *UserTokenValidateCommand) Execute(ctx context.Context, input UserTokenValidateInput) error
Execute validates the token and returns the payload.
type UserTokenValidateInput ¶ added in v0.11.0
type UserTokenValidateInput struct {
Token string
TokenType types.UserTokenType
Scope types.ScopeFilter
Result *UserTokenValidateResult
}
UserTokenValidateInput validates an onboarding token without consuming it.
func (UserTokenValidateInput) Type ¶ added in v0.11.0
func (UserTokenValidateInput) Type() string
Type implements gocommand.Message.
func (UserTokenValidateInput) Validate ¶ added in v0.11.0
func (input UserTokenValidateInput) Validate() error
Validate implements gocommand.Message.
type UserTokenValidateResult ¶ added in v0.11.0
type UserTokenValidateResult struct {
Token *types.UserToken
Payload types.SecureLinkPayload
}
UserTokenValidateResult exposes the decoded payload and token record.
type UserUpdateCommand ¶ added in v0.6.0
type UserUpdateCommand struct {
// contains filtered or unexported fields
}
UserUpdateCommand updates existing users while enforcing scopes.
func NewUserUpdateCommand ¶ added in v0.6.0
func NewUserUpdateCommand(cfg UserUpdateCommandConfig) *UserUpdateCommand
NewUserUpdateCommand constructs the update handler.
func (*UserUpdateCommand) Execute ¶ added in v0.6.0
func (c *UserUpdateCommand) Execute(ctx context.Context, input UserUpdateInput) error
Execute updates the user record and logs audit metadata.
type UserUpdateCommandConfig ¶ added in v0.6.0
type UserUpdateCommandConfig struct {
Repository types.AuthRepository
Policy types.TransitionPolicy
Clock types.Clock
Activity types.ActivitySink
Hooks types.Hooks
Logger types.Logger
ScopeGuard scope.Guard
}
UserUpdateCommandConfig wires dependencies for the update command.
type UserUpdateInput ¶ added in v0.6.0
type UserUpdateInput struct {
User *types.AuthUser
Actor types.ActorRef
Scope types.ScopeFilter
Result *types.AuthUser
}
UserUpdateInput captures the payload for user updates.
func (UserUpdateInput) Type ¶ added in v0.6.0
func (UserUpdateInput) Type() string
Type implements gocommand.Message.
func (UserUpdateInput) Validate ¶ added in v0.6.0
func (input UserUpdateInput) Validate() error
Validate implements gocommand.Message.
Source Files
¶
- activity_enrichment.go
- activity_log.go
- bulk_import.go
- bulk_lifecycle.go
- doc.go
- errors.go
- feature_gate.go
- internal_helpers.go
- invite.go
- lifecycle.go
- password_reset.go
- password_reset_confirm.go
- password_reset_request.go
- preference_delete.go
- preference_upsert.go
- profile_upsert.go
- registration_request.go
- role_assign.go
- role_create.go
- role_delete.go
- role_helpers.go
- role_update.go
- securelink_helpers.go
- token_validation.go
- user_create.go
- user_helpers.go
- user_update.go