From: Nutomic Date: Mon, 25 Apr 2022 21:16:29 +0000 (+0200) Subject: Dont return "admin" for GET user when no id/name is provided (fixes #1546) (#2233) X-Git-Url: http://these/git/%22https:/nerdica.net/photo/contact/80/README.ja.md?a=commitdiff_plain;h=3488b9aeb5a0b97e9a77fc0c4f75196662043e71;p=lemmy.git Dont return "admin" for GET user when no id/name is provided (fixes #1546) (#2233) --- diff --git a/crates/api_crud/src/user/read.rs b/crates/api_crud/src/user/read.rs index 55cc219b..839f46f2 100644 --- a/crates/api_crud/src/user/read.rs +++ b/crates/api_crud/src/user/read.rs @@ -46,15 +46,16 @@ impl PerformCrud for GetPersonDetails { let person_details_id = match data.person_id { Some(id) => id, None => { - let name = data - .username - .to_owned() - .unwrap_or_else(|| "admin".to_string()); - - resolve_actor_identifier::(&name, context) - .await - .map_err(|e| e.with_message("couldnt_find_that_username_or_email"))? - .id + if let Some(username) = &data.username { + resolve_actor_identifier::(username, context) + .await + .map_err(|e| e.with_message("couldnt_find_that_username_or_email"))? + .id + } else { + return Err(LemmyError::from_message( + "couldnt_find_that_username_or_email", + )); + } } };