Improved error handling (part 4)
This commit is contained in:
@@ -24,7 +24,7 @@ impl Directory {
|
||||
DirectoryInner::Smtp(store) => store.query(by).await,
|
||||
DirectoryInner::Memory(store) => store.query(by).await,
|
||||
}
|
||||
.caused_by( trc::location!())
|
||||
.caused_by(trc::location!())
|
||||
}
|
||||
|
||||
pub async fn email_to_ids(&self, email: &str) -> trc::Result<Vec<u32>> {
|
||||
@@ -36,7 +36,7 @@ impl Directory {
|
||||
DirectoryInner::Smtp(store) => store.email_to_ids(email).await,
|
||||
DirectoryInner::Memory(store) => store.email_to_ids(email).await,
|
||||
}
|
||||
.caused_by( trc::location!())
|
||||
.caused_by(trc::location!())
|
||||
}
|
||||
|
||||
pub async fn is_local_domain(&self, domain: &str) -> trc::Result<bool> {
|
||||
@@ -55,7 +55,7 @@ impl Directory {
|
||||
DirectoryInner::Smtp(store) => store.is_local_domain(domain).await,
|
||||
DirectoryInner::Memory(store) => store.is_local_domain(domain).await,
|
||||
}
|
||||
.caused_by( trc::location!())?;
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
// Update cache
|
||||
if let Some(cache) = &self.cache {
|
||||
@@ -81,7 +81,7 @@ impl Directory {
|
||||
DirectoryInner::Smtp(store) => store.rcpt(email).await,
|
||||
DirectoryInner::Memory(store) => store.rcpt(email).await,
|
||||
}
|
||||
.caused_by( trc::location!())?;
|
||||
.caused_by(trc::location!())?;
|
||||
|
||||
// Update cache
|
||||
if let Some(cache) = &self.cache {
|
||||
@@ -100,7 +100,7 @@ impl Directory {
|
||||
DirectoryInner::Smtp(store) => store.vrfy(address).await,
|
||||
DirectoryInner::Memory(store) => store.vrfy(address).await,
|
||||
}
|
||||
.caused_by( trc::location!())
|
||||
.caused_by(trc::location!())
|
||||
}
|
||||
|
||||
pub async fn expn(&self, address: &str) -> trc::Result<Vec<String>> {
|
||||
@@ -112,6 +112,6 @@ impl Directory {
|
||||
DirectoryInner::Smtp(store) => store.expn(address).await,
|
||||
DirectoryInner::Memory(store) => store.expn(address).await,
|
||||
}
|
||||
.caused_by( trc::location!())
|
||||
.caused_by(trc::location!())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ impl<T: serde::Serialize + serde::de::DeserializeOwned> Principal<T> {
|
||||
// Token needs to validate with at least one of the TOTP secrets
|
||||
is_totp_verified = TOTP::from_url(secret)
|
||||
.map_err(|err| {
|
||||
trc::AuthCause::Invalid
|
||||
trc::AuthCause::Error
|
||||
.reason(err)
|
||||
.details(secret.to_string())
|
||||
})?
|
||||
@@ -128,7 +128,7 @@ async fn verify_hash_prefix(hashed_secret: &str, secret: &str) -> trc::Result<bo
|
||||
.ok();
|
||||
}
|
||||
Err(err) => {
|
||||
tx.send(Err(trc::AuthCause::Invalid
|
||||
tx.send(Err(trc::AuthCause::Error
|
||||
.reason(err)
|
||||
.details(hashed_secret)))
|
||||
.ok();
|
||||
@@ -155,7 +155,7 @@ async fn verify_hash_prefix(hashed_secret: &str, secret: &str) -> trc::Result<bo
|
||||
// MD5 based hash
|
||||
Ok(md5_crypt::verify(secret, hashed_secret))
|
||||
} else {
|
||||
Err(trc::AuthCause::Invalid
|
||||
Err(trc::AuthCause::Error
|
||||
.into_err()
|
||||
.details(hashed_secret.to_string()))
|
||||
}
|
||||
@@ -256,12 +256,12 @@ pub async fn verify_secret_hash(hashed_secret: &str, secret: &str) -> trc::Resul
|
||||
}
|
||||
}
|
||||
"PLAIN" | "plain" | "CLEAR" | "clear" => Ok(hashed_secret == secret),
|
||||
_ => Err(trc::AuthCause::Invalid
|
||||
_ => Err(trc::AuthCause::Error
|
||||
.ctx(trc::Key::Reason, "Unsupported algorithm")
|
||||
.details(hashed_secret.to_string())),
|
||||
}
|
||||
} else {
|
||||
Err(trc::AuthCause::Invalid
|
||||
Err(trc::AuthCause::Error
|
||||
.into_err()
|
||||
.details(hashed_secret.to_string()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user