Warning fixes

This commit is contained in:
kdeng00
2025-07-31 23:08:09 -04:00
parent 83a1c9ce47
commit 78be4363ed
+2 -25
View File
@@ -2,7 +2,6 @@
// use std::sync::Arc; // use std::sync::Arc;
use axum::{ use axum::{
// extract::State,
http::{Request, StatusCode}, http::{Request, StatusCode},
middleware::Next, middleware::Next,
response::{IntoResponse}, response::{IntoResponse},
@@ -64,12 +63,6 @@ pub enum JwtError {
InvalidKey, InvalidKey,
} }
/*
pub struct JwtAuth {
key: Jwk, // Now properly parameterized
}
*/
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
pub struct ErrorResponse { pub struct ErrorResponse {
@@ -79,8 +72,7 @@ pub struct ErrorResponse {
pub async fn auth<B>( pub async fn auth<B>(
cookie_jar: CookieJar, cookie_jar: CookieJar,
// State(data): State<Arc<AppState>>, req: Request<axum::body::Body>,
mut req: Request<axum::body::Body>,
next: Next, next: Next,
) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> { ) -> Result<impl IntoResponse, (StatusCode, Json<ErrorResponse>)> {
println!("Cookie: {cookie_jar:?}"); println!("Cookie: {cookie_jar:?}");
@@ -94,11 +86,7 @@ pub async fn auth<B>(
.and_then(|auth_header| auth_header.to_str().ok()) .and_then(|auth_header| auth_header.to_str().ok())
.and_then(|auth_value| { .and_then(|auth_value| {
println!("Auth value: {auth_value:?}"); println!("Auth value: {auth_value:?}");
if let Some(stripped) = auth_value.strip_prefix("Bearer ") { auth_value.strip_prefix("Bearer ").map(String::from)
Some(String::from(stripped))
} else {
None
}
}) })
}); });
@@ -132,16 +120,5 @@ pub async fn auth<B>(
println!("Claims: {claims:?}"); 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) Ok(next.run(req).await)
} }