rustfmt and simplify
This commit is contained in:
parent
6022dd7cf7
commit
a406f059e3
|
@ -11,7 +11,8 @@ struct Claims {
|
|||
|
||||
pub async fn validate_token(token: &str) -> Result<bool, ServiceError> {
|
||||
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<bool, ServiceError> {
|
|||
}
|
||||
|
||||
async fn fetch_jwks(uri: &str) -> anyhow::Result<JWKS> {
|
||||
let res = reqwest::get(uri).await?;
|
||||
let val = res.json::<JWKS>().await?;
|
||||
return Ok(val);
|
||||
Ok(reqwest::get(uri).await?.json::<JWKS>().await?)
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ pub struct InputUser {
|
|||
|
||||
pub async fn get_users(db: web::Data<Pool>) -> Result<HttpResponse, Error> {
|
||||
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<Pool>) -> Result<Vec<User>, diesel::result::Error> {
|
||||
|
|
|
@ -18,4 +18,3 @@ pub struct NewUser<'a> {
|
|||
pub email: &'a str,
|
||||
pub created_at: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue