block empty passwords in the web handler

This commit is contained in:
2026-04-26 16:08:31 +02:00
parent fac1959193
commit 7d418c91e4

View File

@@ -113,6 +113,14 @@ pub async fn change_password(
headers: HeaderMap,
Form(form): Form<PasswordForm>,
) -> Result<Response, CompositeError> {
if form.password.trim().is_empty() {
return Ok((
axum::http::StatusCode::BAD_REQUEST,
"Password cannot be empty or consist only of whitespace.",
)
.into_response());
}
let mut tx = state.pool.begin().await?;
let mut u = User::authenticate(&mut *tx, &headers).await?.required()?;