From 78be4363edaad270499e4bef837681eda1d9e1a9 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Thu, 31 Jul 2025 23:08:09 -0400 Subject: [PATCH] Warning fixes --- src/auth.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/auth.rs b/src/auth.rs index e25b5b2..104182a 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -2,7 +2,6 @@ // use std::sync::Arc; use axum::{ - // extract::State, http::{Request, StatusCode}, middleware::Next, response::{IntoResponse}, @@ -64,12 +63,6 @@ pub enum JwtError { InvalidKey, } -/* -pub struct JwtAuth { - key: Jwk, // Now properly parameterized -} -*/ - #[derive(Debug, Serialize)] pub struct ErrorResponse { @@ -79,8 +72,7 @@ pub struct ErrorResponse { pub async fn auth( cookie_jar: CookieJar, - // State(data): State>, - mut req: Request, + req: Request, next: Next, ) -> Result)> { println!("Cookie: {cookie_jar:?}"); @@ -94,11 +86,7 @@ pub async fn auth( .and_then(|auth_header| auth_header.to_str().ok()) .and_then(|auth_value| { println!("Auth value: {auth_value:?}"); - if let Some(stripped) = auth_value.strip_prefix("Bearer ") { - Some(String::from(stripped)) - } else { - None - } + auth_value.strip_prefix("Bearer ").map(String::from) }) }); @@ -132,16 +120,5 @@ pub async fn auth( println!("Claims: {claims:?}"); - /* - let user_id = uuid::Uuid::parse_str(&claims.sub).map_err(|_| { - let json_error = ErrorResponse { - status: "fail", - message: "Invalid token".to_string(), - }; - (StatusCode::UNAUTHORIZED, Json(json_error)) - })?; - */ - - // req.extensions_mut().insert(user_id); Ok(next.run(req).await) }