Skip to main content

handle_auth_error

Function handle_auth_error 

Source
pub fn handle_auth_error(
    error: Error,
    username: &str,
) -> Result<(), KindlyError>
Expand description

Example: Handle authentication errors securely

use kindly_guard_server::error::{KindlyError, security_patterns::handle_auth_error};

async fn authenticate(credentials: &Credentials) -> Result<User> {
    match verify_credentials(credentials).await {
        Ok(user) => Ok(user),
        Err(e) => handle_auth_error(e, credentials.username())
    }
}