api_password_reset

package
v0.31.0 Latest Latest
Warning

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

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

Documentation

Index

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

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
}

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

type PasswordResetResult struct {
	SuccessMessage string
	Token          string
}

PasswordResetResult represents a successful password reset.

Jump to

Keyboard shortcuts

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