summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques B <[email protected]>2024-01-26 20:34:36 +0100
committerGitHub <[email protected]>2024-01-26 20:34:36 +0100
commit8b66e3441571fdb71f0610882d1ee47dccc8c0a3 (patch)
treeaa4108de77bfd0b89cff19532714abb25e0a934f
parent1d00e34bbb6d85edb87446017b7f37716fd9ead0 (diff)
downloadvaultwarden-8b66e3441571fdb71f0610882d1ee47dccc8c0a3.tar.gz
vaultwarden-8b66e3441571fdb71f0610882d1ee47dccc8c0a3.zip
Return 404 when user public_key is empty (#4271)
-rw-r--r--src/api/core/accounts.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs
index 72dab64a..a06aa6b7 100644
--- a/src/api/core/accounts.rs
+++ b/src/api/core/accounts.rs
@@ -279,8 +279,9 @@ async fn put_avatar(data: JsonUpcase<AvatarData>, headers: Headers, mut conn: Db
#[get("/users/<uuid>/public-key")]
async fn get_public_keys(uuid: &str, _headers: Headers, mut conn: DbConn) -> JsonResult {
let user = match User::find_by_uuid(uuid, &mut conn).await {
- Some(user) => user,
- None => err!("User doesn't exist"),
+ Some(user) if user.public_key.is_some() => user,
+ Some(_) => err_code!("User has no public_key", Status::NotFound.code),
+ None => err_code!("User doesn't exist", Status::NotFound.code),
};
Ok(Json(json!({