Documentation
¶
Index ¶
- func ApiLoginCodeVerify(w http.ResponseWriter, r *http.Request, deps Dependencies)
- func ApiLoginCodeVerifyWithAuth(w http.ResponseWriter, r *http.Request, a types.AuthSharedInterface)
- func LoginCodeVerify(ctx context.Context, r *http.Request, deps Dependencies) (*LoginCodeVerifyResult, *LoginCodeVerifyError)
- type Dependencies
- type LoginCodeVerifyError
- type LoginCodeVerifyErrorCode
- type LoginCodeVerifyResult
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 ¶
func LoginCodeVerify(ctx context.Context, r *http.Request, deps Dependencies) (*LoginCodeVerifyResult, *LoginCodeVerifyError)
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.