rustfmt and simplify

This commit is contained in:
Cadey Ratio 2020-04-15 22:18:22 -04:00
parent 6022dd7cf7
commit a406f059e3
3 changed files with 6 additions and 8 deletions

View File

@ -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?)
}

View File

@ -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> {

View File

@ -18,4 +18,3 @@ pub struct NewUser<'a> {
pub email: &'a str,
pub created_at: chrono::NaiveDateTime,
}