Update telemetry
Some checks failed
Rust / Test (push) Has been cancelled
Rust / Rustfmt (push) Has been cancelled
Rust / Clippy (push) Has been cancelled
Rust / Code coverage (push) Has been cancelled

This commit is contained in:
Alphonse Paix
2025-09-28 03:37:23 +02:00
parent ac96b3c249
commit 1117d49746
20 changed files with 120 additions and 116 deletions

View File

@@ -31,16 +31,16 @@ pub async fn change_password(
password: form.current_password,
};
if form.new_password.expose_secret() != form.new_password_check.expose_secret() {
Err(AdminError::ChangePassword(
"You entered two different passwords - the field values must match.".to_string(),
)
Err(AdminError::ChangePassword(anyhow::anyhow!(
"You entered two different passwords - the field values must match."
))
.into())
} else if let Err(e) = validate_credentials(credentials, &connection_pool).await {
match e {
AuthError::UnexpectedError(error) => Err(AdminError::UnexpectedError(error).into()),
AuthError::InvalidCredentials(_) => Err(AdminError::ChangePassword(
"The current password is incorrect.".to_string(),
)
AuthError::InvalidCredentials(_) => Err(AdminError::ChangePassword(anyhow::anyhow!(
"The current password is incorrect."
))
.into()),
}
} else if let Err(e) = verify_password(form.new_password.expose_secret()) {
@@ -48,7 +48,7 @@ pub async fn change_password(
} else {
authentication::change_password(user_id, form.new_password, &connection_pool)
.await
.map_err(|e| AdminError::ChangePassword(e.to_string()))?;
.map_err(AdminError::ChangePassword)?;
let template = MessageTemplate::Success {
message: "Your password has been changed.".to_string(),
};
@@ -56,9 +56,9 @@ pub async fn change_password(
}
}
fn verify_password(password: &str) -> Result<(), String> {
fn verify_password(password: &str) -> Result<(), anyhow::Error> {
if password.len() < 12 || password.len() > 128 {
return Err("The password must contain between 12 and 128 characters.".into());
anyhow::bail!("The password must contain between 12 and 128 characters.");
}
Ok(())
}