Skip to content

Commit

Permalink
/searchUser: add "globalInfo" field on first response (instead of add…
Browse files Browse the repository at this point in the history
…ing "allowExtendedInfo" on all users)
  • Loading branch information
prigaux committed Jan 29, 2024
1 parent 3e3e973 commit eb360b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/searchUser.inc.php
Expand Up @@ -59,8 +59,8 @@
global $USER_KEY_FIELD;
$users = searchPeople(people_filters($token, $restriction, $allowInvalidAccounts, $allowNoAffiliationAccounts, $tokenIsId), $attrRestrictions, $wanted_attrs, $USER_KEY_FIELD, $maxRows);

if ($allowExtendedInfo) {
foreach ($users as &$u) $u["allowExtendedInfo"] = $allowExtendedInfo;
if (count($users) > 0 && GET_uid()) {
$users[0]['globalInfo'] = [ "maxRows" => $maxRows, "allowExtendedInfo" => $allowExtendedInfo ];
}

if ($format === 'vcard') {
Expand Down
4 changes: 4 additions & 0 deletions test/run.php
Expand Up @@ -59,6 +59,10 @@ function expect_json($test_name, $ws, $params, $wanted, $remap = null) {
$js = test($ws, $params);
$r = json_decode($js);
if ($r === NULL) fail($test_name, "invalid response\n$js");
if (is_array(($r))) {
// ignore globalInfo
foreach ($r as &$e) unset($e->globalInfo);
}
$got = $remap ? $remap($r) : $r;
$got_s = json_encode($got);
if ($got_s !== $wanted) {
Expand Down
2 changes: 1 addition & 1 deletion web-widget/userinfo/userinfo.js
Expand Up @@ -1301,7 +1301,7 @@ const app = Vue.createApp({
} else if (data.length > 1) {
that.text("internal error (multiple user found)");
} else {
that.allowExtendedInfo = data[0].allowExtendedInfo;
that.allowExtendedInfo = data[0].allowExtendedInfo = data[0].globalInfo?.allowExtendedInfo;
that.text('', data[0]);
}
});
Expand Down

0 comments on commit eb360b3

Please sign in to comment.