From 8b66e3441571fdb71f0610882d1ee47dccc8c0a3 Mon Sep 17 00:00:00 2001 From: Jacques B Date: Fri, 26 Jan 2024 20:34:36 +0100 Subject: [PATCH] Return 404 when user public_key is empty (#4271) --- 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 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, 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!({