Browse Source

cargo clippy and cargo fmt

pull/3870/merge^2
BlockListed 2 years ago
parent
commit
edcd2640d0
No known key found for this signature in database GPG Key ID: 2D204777C477B588
  1. 20
      src/api/core/ciphers.rs
  2. 5
      src/api/core/organizations.rs
  3. 16
      src/auth.rs

20
src/api/core/ciphers.rs

@ -113,14 +113,8 @@ async fn sync(data: SyncData, headers: Headers, mut conn: DbConn) -> Json<Value>
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<Value> {
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,
);
}

5
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)
}

16
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<HostInfo> {
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 {
@ -401,9 +403,7 @@ impl<'r> FromRequest<'r> for HostInfo {
};
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") {

Loading…
Cancel
Save