Fix invalid users/groups handling in advanced search

Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
Benjamin Gaussorgues 2023-11-15 10:13:57 +01:00
parent 830d85bcf1
commit 33837e7d6f
No known key found for this signature in database
GPG key ID: 5DAC1CAFAA6DB883
3 changed files with 8 additions and 5 deletions

View file

@ -28,6 +28,7 @@ declare(strict_types=1);
*/
namespace OC\Core\Controller;
use InvalidArgumentException;
use OC\Search\SearchComposer;
use OC\Search\SearchQuery;
use OCA\Core\ResponseDefinitions;
@ -111,7 +112,7 @@ class UnifiedSearchController extends OCSController {
try {
$filters = $this->composer->buildFilterList($providerId, $this->request->getParams());
} catch (UnsupportedFilter $e) {
} catch (UnsupportedFilter|InvalidArgumentException $e) {
return new DataResponse($e->getMessage(), Http::STATUS_BAD_REQUEST);
}
return new DataResponse(

View file

@ -38,10 +38,11 @@ class GroupFilter implements IFilter {
string $value,
IGroupManager $groupManager,
) {
$this->group = $groupManager->get($value);
if ($this->group === null) {
$group = $groupManager->get($value);
if ($group === null) {
throw new InvalidArgumentException('Group '.$value.' not found');
}
$this->group = $group;
}
public function get(): IGroup {

View file

@ -38,10 +38,11 @@ class UserFilter implements IFilter {
string $value,
IUserManager $userManager,
) {
$this->user = $userManager->get($value);
if ($this->user === null) {
$user = $userManager->get($value);
if ($user === null) {
throw new InvalidArgumentException('User '.$value.' not found');
}
$this->user = $user;
}
public function get(): IUser {