Skip to content

Commit

Permalink
[server] Allow short password in admin/user/change_password #1529 (#1533
Browse files Browse the repository at this point in the history
)

* update

* fix
  • Loading branch information
michaelvlach authored Jan 26, 2025
1 parent 4241247 commit a7c34d5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
2 changes: 0 additions & 2 deletions agdb_api/typescript/src/openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1808,8 +1808,6 @@ declare namespace Paths {
}
export interface $401 {
}
export interface $461 {
}
export interface $464 {
}
}
Expand Down
3 changes: 0 additions & 3 deletions agdb_server/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions agdb_server/src/routes/admin/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ pub(crate) async fn add(
responses(
(status = 201, description = "password changed"),
(status = 401, description = "unauthorized"),
(status = 461, description = "password too short (<8)"),
(status = 464, description = "user not found"),
)
)]
Expand All @@ -87,7 +86,6 @@ pub(crate) async fn change_password(
Json(request): Json<UserCredentials>,
) -> ServerResponse<impl IntoResponse> {
let _user = server_db.user_id(&username).await?;
password::validate_password(&request.password)?;
let pswd = Password::create(&username, &request.password);

let (commit_index, _result) = cluster
Expand Down
11 changes: 3 additions & 8 deletions agdb_server/tests/routes/admin_user_change_password_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@ async fn change_password() -> anyhow::Result<()> {
}

#[tokio::test]
async fn password_too_short() -> anyhow::Result<()> {
async fn password_short() -> anyhow::Result<()> {
let mut server = TestServer::new().await?;
let owner = &next_user_name();
server.api.user_login(ADMIN, ADMIN).await?;
server.api.admin_user_add(owner, owner).await?;
let status = server
.api
.admin_user_change_password(owner, "pswd")
.await
.unwrap_err()
.status;
assert_eq!(status, 461);
let status = server.api.admin_user_change_password(owner, "pswd").await?;
assert_eq!(status, 201);
Ok(())
}

Expand Down

0 comments on commit a7c34d5

Please sign in to comment.