Documentation
¶
Index ¶
- func ApiPasswordReset(w http.ResponseWriter, r *http.Request, deps Dependencies)
- func ApiPasswordResetWithAuth(w http.ResponseWriter, r *http.Request, a types.AuthSharedInterface)
- func PasswordReset(ctx context.Context, r *http.Request, deps Dependencies) (*PasswordResetResult, *PasswordResetError)
- type Dependencies
- type PasswordResetError
- type PasswordResetErrorCode
- type PasswordResetResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApiPasswordReset ¶
func ApiPasswordReset(w http.ResponseWriter, r *http.Request, deps Dependencies)
ApiPasswordReset is the HTTP-level helper that wires request/response handling to the core PasswordReset business logic using the provided dependencies.
func ApiPasswordResetWithAuth ¶
func ApiPasswordResetWithAuth(w http.ResponseWriter, r *http.Request, a types.AuthSharedInterface)
ApiPasswordResetWithAuth 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 PasswordReset ¶
func PasswordReset(ctx context.Context, r *http.Request, deps Dependencies) (*PasswordResetResult, *PasswordResetError)
PasswordReset encapsulates the core business logic for resetting a user's password based on a reset token. It does not log or write HTTP responses.
Types ¶
type Dependencies ¶
type Dependencies struct {
PasswordStrength *types.PasswordStrengthConfig
TemporaryKeyGet func(key string) (string, error)
UserPasswordChange func(ctx context.Context, userID, password string) error
LogoutUser func(ctx context.Context, userID string) error
// Logger is used to log internal errors. If nil, slog.Default() is used.
Logger *slog.Logger
}
Dependencies defines the dependencies required for the password reset flow (changing the user's password given a valid token).
type PasswordResetError ¶
type PasswordResetError struct {
Code PasswordResetErrorCode
Message string
Err error
UserID string
}
PasswordResetError represents a structured error for password reset.
func (*PasswordResetError) Error ¶
func (e *PasswordResetError) Error() string
type PasswordResetErrorCode ¶
type PasswordResetErrorCode string
PasswordResetErrorCode categorizes error sources in the password reset flow.
const ( PasswordResetErrorCodeNone PasswordResetErrorCode = "" PasswordResetErrorCodeValidation PasswordResetErrorCode = "validation" PasswordResetErrorCodePasswordStrength PasswordResetErrorCode = "password_strength" PasswordResetErrorCodeTokenLookup PasswordResetErrorCode = "token_lookup" PasswordResetErrorCodeTokenInvalid PasswordResetErrorCode = "token_invalid" PasswordResetErrorCodePasswordChange PasswordResetErrorCode = "password_change" PasswordResetErrorCodeLogout PasswordResetErrorCode = "logout" PasswordResetErrorCodeInternal PasswordResetErrorCode = "internal" )
type PasswordResetResult ¶
PasswordResetResult represents a successful password reset.