api_register_code_verify

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiRegisterCodeVerify

func ApiRegisterCodeVerify(w http.ResponseWriter, r *http.Request, deps Dependencies)

ApiRegisterCodeVerify is the HTTP-level helper that wires request/response handling to the core RegisterCodeVerify business logic using the provided dependencies.

func ApiRegisterCodeVerifyWithAuth

func ApiRegisterCodeVerifyWithAuth(w http.ResponseWriter, r *http.Request, a types.AuthSharedInterface)

ApiRegisterCodeVerifyWithAuth is a convenience wrapper that allows callers to pass a types.AuthSharedInterface (such as authImplementation) instead of manually wiring Dependencies. It constructs the Dependencies struct using the interface accessors and preserves the existing behaviour.

func RegisterCodeVerify

RegisterCodeVerify encapsulates the core business logic for verifying a registration code, performing optional password validation and creating the user. It does not log or write HTTP responses.

Types

type Dependencies

type Dependencies struct {
	DisableRateLimit bool

	TemporaryKeyGet func(key string) (string, error)

	PasswordStrength *types.PasswordStrengthConfig

	Passwordless bool

	PasswordlessUserRegister func(ctx context.Context, email, firstName, lastName string) error
	UserRegister             func(ctx context.Context, email, password, firstName, lastName string) error

	// AuthenticateViaUsername is called on successful registration to
	// authenticate the user and produce the final HTTP response.
	AuthenticateViaUsername func(w http.ResponseWriter, r *http.Request, email, firstName, lastName string)

	// Logger is used to log internal errors. If nil, slog.Default() is used.
	Logger *slog.Logger
}

Dependencies defines the dependencies required for verifying a registration code, creating the user account, and authenticating the user.

type RegisterCodeVerifyError

type RegisterCodeVerifyError struct {
	Code    RegisterCodeVerifyErrorCode
	Message string
	Err     error
}

RegisterCodeVerifyError represents a structured error.

func (*RegisterCodeVerifyError) Error

func (e *RegisterCodeVerifyError) Error() string

type RegisterCodeVerifyErrorCode

type RegisterCodeVerifyErrorCode string

RegisterCodeVerifyErrorCode categorizes error sources in the registration code verification flow.

const (
	RegisterCodeVerifyErrorCodeNone               RegisterCodeVerifyErrorCode = ""
	RegisterCodeVerifyErrorCodeValidation         RegisterCodeVerifyErrorCode = "validation"
	RegisterCodeVerifyErrorCodeCodeExpired        RegisterCodeVerifyErrorCode = "code_expired"
	RegisterCodeVerifyErrorCodeDeserialize        RegisterCodeVerifyErrorCode = "deserialize"
	RegisterCodeVerifyErrorCodePasswordValidation RegisterCodeVerifyErrorCode = "password_validation"
	RegisterCodeVerifyErrorCodeRegister           RegisterCodeVerifyErrorCode = "register"
)

type RegisterCodeVerifyResult

type RegisterCodeVerifyResult struct {
	Email     string
	FirstName string
	LastName  string
}

RegisterCodeVerifyResult represents a successful verification.

Jump to

Keyboard shortcuts

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