diff --git a/src/auth.rs b/src/auth.rs index f7d4595..82ea009 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -11,7 +11,8 @@ struct Claims { pub async fn validate_token(token: &str) -> Result { let domain = std::env::var("DOMAIN").expect("DOMAIN must be set"); - let jwks = fetch_jwks(&format!("{}{}", domain.as_str(), ".well-known/jwks.json")).await + let jwks = fetch_jwks(&format!("{}{}", domain.as_str(), ".well-known/jwks.json")) + .await .expect("failed to fetch jwks"); let validations = vec![Validation::Issuer(domain), Validation::SubjectPresent]; let kid = match token_kid(&token) { @@ -24,7 +25,5 @@ pub async fn validate_token(token: &str) -> Result { } async fn fetch_jwks(uri: &str) -> anyhow::Result { - let res = reqwest::get(uri).await?; - let val = res.json::().await?; - return Ok(val); + Ok(reqwest::get(uri).await?.json::().await?) } diff --git a/src/handlers.rs b/src/handlers.rs index 7140675..079804a 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -17,9 +17,9 @@ pub struct InputUser { pub async fn get_users(db: web::Data) -> Result { Ok(web::block(move || get_all_users(db)) - .await - .map(|user| HttpResponse::Ok().json(user)) - .map_err(|_| HttpResponse::InternalServerError())?) + .await + .map(|user| HttpResponse::Ok().json(user)) + .map_err(|_| HttpResponse::InternalServerError())?) } fn get_all_users(pool: web::Data) -> Result, diesel::result::Error> { diff --git a/src/models.rs b/src/models.rs index e57cb86..0849eb6 100644 --- a/src/models.rs +++ b/src/models.rs @@ -18,4 +18,3 @@ pub struct NewUser<'a> { pub email: &'a str, pub created_at: chrono::NaiveDateTime, } -