Skip to content

Commit

Permalink
Fix REST API bugs introduced in PR 303 and CFM-411
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jul 6, 2025
1 parent d5c4238 commit 15008bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion app/src/Controller/ApiV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ protected function dispatchIndex(string $mode = 'default') {
// Construct the Query
$query = $this->getIndexQuery($pickerMode, $reqParameters);

if(method_exists($table, 'findIndexed')) {
// findIndexed breaks the REST API (which doesn't pull related models),
// so only use it in Picker Mode
if($pickerMode && method_exists($table, 'findIndexed')) {
$query = $table->findIndexed($query);
}

// This magically makes REST calls paginated... can use eg direction=,
// sort=, limit=, page=
$this->set($this->tableName, $this->paginate($query));
Expand Down
9 changes: 6 additions & 3 deletions app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -956,17 +956,20 @@ public function isPlatformAdmin(): bool {
/**
* Determine if the current user is acting as themselves within the specified CO.
*
* @param int|null $coId CO ID
* @param int|null $id ID
* @return bool True if the current user is acting as themselves
* @since COmanage Registry v5.1.0
* @param int|null $coId CO ID
* @param int|null $id ID
* @return bool True if the current user is acting as themselves
*/

public function isSelf(?int $coId, ?int $id): bool {
// We might get called in some contexts without a coId, in which case there
// are no members.

if(!$coId
|| empty($this->cache['isCoMember'][$coId])
// API Users can't be self and getPersonID() will throw errors if called by one
|| $this->isApiUser()
) {
return false;
}
Expand Down

0 comments on commit 15008bc

Please sign in to comment.