Skip to content

Commit

Permalink
fix: make filter routes available for normal users
Browse files Browse the repository at this point in the history
1) The NoAdminRequired attribute is required to make the route available for non-admins.

2) Changing OCSController to Controller to respond with a proper error code on a failing request.

Signed-off-by: Daniel Kesselberg <[email protected]>
  • Loading branch information
kesselb committed Dec 21, 2024
1 parent a959a81 commit 95984e8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/Controller/FilterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
use OCA\Mail\AppInfo\Application;
use OCA\Mail\Service\AccountService;
use OCA\Mail\Service\FilterService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\Route;
use OCP\AppFramework\Http\JSONResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;

class FilterController extends OCSController {
class FilterController extends Controller {
private string $currentUserId;

public function __construct(
Expand All @@ -31,7 +32,9 @@ public function __construct(
$this->currentUserId = $userId;
}


#[Route(Route::TYPE_FRONTPAGE, verb: 'GET', url: '/api/filter/{accountId}', requirements: ['accountId' => '[\d]+'])]
#[NoAdminRequired]
public function getFilters(int $accountId) {
$account = $this->accountService->findById($accountId);

Expand All @@ -45,6 +48,7 @@ public function getFilters(int $accountId) {
}

#[Route(Route::TYPE_FRONTPAGE, verb: 'PUT', url: '/api/filter/{accountId}', requirements: ['accountId' => '[\d]+'])]
#[NoAdminRequired]
public function updateFilters(int $accountId, array $filters) {
$account = $this->accountService->findById($accountId);

Expand Down

0 comments on commit 95984e8

Please sign in to comment.