Page MenuHomePhorge

Include email address in Conduit's user.query output when run by admin
ActivePublic

Authored by aklapper on Jun 13 2023, 13:32.
diff --git a/src/applications/people/conduit/UserQueryConduitAPIMethod.php b/src/applications/people/conduit/UserQueryConduitAPIMethod.php
index df0ec65841..0a99ab437e 100644
--- a/src/applications/people/conduit/UserQueryConduitAPIMethod.php
+++ b/src/applications/people/conduit/UserQueryConduitAPIMethod.php
@@ -80,11 +80,22 @@ final class UserQueryConduitAPIMethod extends UserConduitAPIMethod {
$users = $query->execute();
$results = array();
+
+ $actor = $request->getUser();
+ $is_admin = $actor->getIsAdmin();
+
foreach ($users as $user) {
- $results[] = $this->buildUserInformationDictionary(
- $user,
- $with_email = false,
- $with_availability = true);
+ if ($is_admin) {
+ $results[] = $this->buildUserInformationDictionary(
+ $user,
+ $with_email = true,
+ $with_availability = true);
+ } else {
+ $results[] = $this->buildUserInformationDictionary(
+ $user,
+ $with_email = false,
+ $with_availability = true);
+ }
}
return $results;
}