From 3488b9aeb5a0b97e9a77fc0c4f75196662043e71 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 25 Apr 2022 23:16:29 +0200 Subject: [PATCH] Dont return "admin" for GET user when no id/name is provided (fixes #1546) (#2233) --- crates/api_crud/src/user/read.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) 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", + )); + } } }; -- 2.44.1