From c4b0bf089be3b66f4fd2ede1ccca3de9436862ca Mon Sep 17 00:00:00 2001 From: Timshel Date: Fri, 26 Jan 2024 19:53:40 +0100 Subject: [PATCH] Return 404 when user public_key is empty --- src/api/core/accounts.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index 72dab64a3f..a06aa6b714 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -279,8 +279,9 @@ async fn put_avatar(data: JsonUpcase, headers: Headers, mut conn: Db #[get("/users//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!({