block empty passwords in the web handler
This commit is contained in:
@@ -113,6 +113,14 @@ pub async fn change_password(
|
|||||||
headers: HeaderMap,
|
headers: HeaderMap,
|
||||||
Form(form): Form<PasswordForm>,
|
Form(form): Form<PasswordForm>,
|
||||||
) -> Result<Response, CompositeError> {
|
) -> 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 tx = state.pool.begin().await?;
|
||||||
let mut u = User::authenticate(&mut *tx, &headers).await?.required()?;
|
let mut u = User::authenticate(&mut *tx, &headers).await?.required()?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user