Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApiLogout ¶
func ApiLogout(w http.ResponseWriter, r *http.Request, deps Dependencies)
ApiLogout is the HTTP-level helper that wires request/response handling to the core ApiLogout business logic using the provided dependencies.
func ApiLogoutWithAuth ¶
func ApiLogoutWithAuth(w http.ResponseWriter, r *http.Request, a types.AuthSharedInterface)
ApiLogoutWithAuth 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.
Types ¶
type Dependencies ¶
type Dependencies struct {
// UserFromToken resolves a user ID from the provided authentication token.
UserFromToken func(ctx context.Context, token string) (userID string, err error)
// LogoutUser performs the actual user logout.
LogoutUser func(ctx context.Context, userID string) error
// UseCookies indicates whether the auth token is stored in cookies and
// should be removed on successful logout.
UseCookies bool
// AuthTokenRetrieve extracts the authentication token from the HTTP
// request, typically from cookies or headers.
AuthTokenRetrieve func(r *http.Request, useCookies bool) string
// RemoveAuthCookie removes the authentication cookie after a successful
// logout when UseCookies is true.
RemoveAuthCookie func(w http.ResponseWriter, r *http.Request)
}
Dependencies defines the dependencies required for performing a logout. The concrete implementation details (how to look up a user from a token and how to log a user out) are provided by the caller via these function fields.
type LogoutError ¶
type LogoutError struct {
Code LogoutErrorCode
Err error
UserID string
}
LogoutError represents a structured error for the logout flow.
func (*LogoutError) Error ¶
func (e *LogoutError) Error() string
type LogoutErrorCode ¶
type LogoutErrorCode string
LogoutErrorCode categorizes error sources in the logout flow.
const ( LogoutErrorCodeNone LogoutErrorCode = "" LogoutErrorCodeTokenLookup LogoutErrorCode = "token_lookup" LogoutErrorCodeUserLogout LogoutErrorCode = "user_logout" )