]> Untitled Git - lemmy.git/commitdiff
Dont return "admin" for GET user when no id/name is provided (fixes #1546) (#2233)
authorNutomic <me@nutomic.com>
Mon, 25 Apr 2022 21:16:29 +0000 (23:16 +0200)
committerGitHub <noreply@github.com>
Mon, 25 Apr 2022 21:16:29 +0000 (21:16 +0000)
crates/api_crud/src/user/read.rs

index 55cc219be99faac2958f25948eb6b27942c57fba..839f46f2c547c9bf9c32ce6268be55db4b54e045 100644 (file)
@@ -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::<ApubPerson, Person>(&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::<ApubPerson, Person>(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",
+          ));
+        }
       }
     };