Skip to content

Commit

Permalink
Issue 404 when getting user profile that isn't in a group different f…
Browse files Browse the repository at this point in the history
…rom default or private
  • Loading branch information
jjrom committed Dec 16, 2024
1 parent a4c8b48 commit 82c7e71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 7 additions & 1 deletion app/resto/core/api/GroupAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,17 @@ public function __construct($context, $user)
*/
public function getGroups($params)
{
return array(
$groups = array(
'groups' => (new GroupsFunctions($this->context->dbDriver))->getGroups(array(
'q' => $params['q'] ?? null
))
);

if ( empty($groups) ) {
RestoLogUtil::httpError(400);
}

return $groups;
}

/**
Expand Down
7 changes: 1 addition & 6 deletions app/resto/core/dbfunctions/GroupsFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ public function getGroups($params = array())

$results = $this->dbDriver->fetch($this->dbDriver->query('SELECT name, description, id, to_iso8601(created) as created FROM ' . $this->dbDriver->commonSchema . '.group' . (count($where) > 0 ? ' WHERE ' . join(' AND ', $where) : '') . ' ORDER BY id DESC'));

// 404 if no empty results when id is specified
if ( empty($results) ) {
RestoLogUtil::httpError(404);
}

return $results;
return empty($results) ? array() : $results;

}

Expand Down

0 comments on commit 82c7e71

Please sign in to comment.