diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 301dc29f..62c960ea 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -113,14 +113,8 @@ async fn sync(data: SyncData, headers: Headers, mut conn: DbConn) -> Json let mut ciphers_json = Vec::with_capacity(ciphers.len()); for c in ciphers { ciphers_json.push( - c.to_json( - &headers.base_url, - &headers.user.uuid, - Some(&cipher_sync_data), - CipherSyncType::User, - &mut conn, - ) - .await, + c.to_json(&headers.base_url, &headers.user.uuid, Some(&cipher_sync_data), CipherSyncType::User, &mut conn) + .await, ); } @@ -166,14 +160,8 @@ async fn get_ciphers(headers: Headers, mut conn: DbConn) -> Json { let mut ciphers_json = Vec::with_capacity(ciphers.len()); for c in ciphers { ciphers_json.push( - c.to_json( - &headers.base_url, - &headers.user.uuid, - Some(&cipher_sync_data), - CipherSyncType::User, - &mut conn, - ) - .await, + c.to_json(&headers.base_url, &headers.user.uuid, Some(&cipher_sync_data), CipherSyncType::User, &mut conn) + .await, ); } diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index 9975ee5e..4ff41139 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -777,9 +777,8 @@ async fn _get_org_details(org_id: &str, base_url: &str, user_uuid: &str, conn: & let mut ciphers_json = Vec::with_capacity(ciphers.len()); for c in ciphers { - ciphers_json.push( - c.to_json(base_url, user_uuid, Some(&cipher_sync_data), CipherSyncType::Organization, conn).await, - ); + ciphers_json + .push(c.to_json(base_url, user_uuid, Some(&cipher_sync_data), CipherSyncType::Organization, conn).await); } json!(ciphers_json) } diff --git a/src/auth.rs b/src/auth.rs index 57534769..c095a1ae 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -9,7 +9,7 @@ use openssl::rsa::Rsa; use serde::de::DeserializeOwned; use serde::ser::Serialize; -use crate::config::{extract_url_origin, extract_url_host}; +use crate::config::{extract_url_host, extract_url_origin}; use crate::{error::Error, CONFIG}; const JWT_ALGORITHM: Algorithm = Algorithm::RS256; @@ -372,10 +372,12 @@ pub struct HostInfo { } fn get_host_info(host: &str) -> Option { - CONFIG - .host_to_domain(host) - .and_then(|base_url| Some((base_url, CONFIG.domain_origin(host)?))) - .and_then(|(base_url, origin)| Some(HostInfo { base_url, origin })) + CONFIG.host_to_domain(host).and_then(|base_url| Some((base_url, CONFIG.domain_origin(host)?))).map( + |(base_url, origin)| HostInfo { + base_url, + origin, + }, + ) } fn get_main_host() -> String { @@ -399,11 +401,9 @@ impl<'r> FromRequest<'r> for HostInfo { } else { get_main_host().into() }; - + let host_info = get_host_info(host.as_ref()) - .unwrap_or_else(|| { - get_host_info(&get_main_host()).expect("Main domain doesn't have entry!") - }); + .unwrap_or_else(|| get_host_info(&get_main_host()).expect("Main domain doesn't have entry!")); return Outcome::Success(host_info); } else if let Some(referer) = headers.get_one("Referer") {