api_login_code_verify

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApiLoginCodeVerify

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

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

func ApiLoginCodeVerifyWithAuth

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

ApiLoginCodeVerifyWithAuth 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 LoginCodeVerify

LoginCodeVerify encapsulates the core business logic for verifying a passwordless login code. It mirrors the original validation rules and error messages but does not perform authentication or write HTTP responses.

Types

type Dependencies

type Dependencies struct {
	DisableRateLimit bool

	TemporaryKeyGet func(key string) (string, error)

	// AuthenticateViaUsername is called on successful code verification
	// to perform authentication (token generation, cookies, etc.) and send
	// the final HTTP response.
	AuthenticateViaUsername func(w http.ResponseWriter, r *http.Request, email string)

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

Dependencies defines dependencies for verifying a passwordless login code and authenticating the user.

type LoginCodeVerifyError

type LoginCodeVerifyError struct {
	Code    LoginCodeVerifyErrorCode
	Message string
	Err     error
}

LoginCodeVerifyError represents a structured error in the login code verification flow.

func (*LoginCodeVerifyError) Error

func (e *LoginCodeVerifyError) Error() string

type LoginCodeVerifyErrorCode

type LoginCodeVerifyErrorCode string

LoginCodeVerifyErrorCode categorizes error sources.

const (
	LoginCodeVerifyErrorCodeNone        LoginCodeVerifyErrorCode = ""
	LoginCodeVerifyErrorCodeValidation  LoginCodeVerifyErrorCode = "validation"
	LoginCodeVerifyErrorCodeCodeExpired LoginCodeVerifyErrorCode = "code_expired"
)

type LoginCodeVerifyResult

type LoginCodeVerifyResult struct {
	Email string
}

LoginCodeVerifyResult represents a successful verification.

Jump to

Keyboard shortcuts

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