Skip to content

Commit

Permalink
add permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 committed Jan 8, 2024
1 parent 2280e03 commit 2878b3b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use Pimcore\Controller\UserAwareController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\RouterInterface;

Expand All @@ -40,6 +41,11 @@ public function __construct(private RouterInterface $router)
$this->router = $router;
}

public function onKernelControllerEvent(ControllerEvent $event): void
{
$this->checkPermission('bundle_ecommerce_back-office_order');
}

/**
* @Route("/js-config", name="pimcore_ecommerceframework_config_jsconfig", methods={"GET"})
*
Expand Down
6 changes: 6 additions & 0 deletions src/Controller/FindologicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Pimcore\Controller\FrontendController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerEvent;

/**
* Class FindologicController
Expand All @@ -29,6 +30,11 @@
*/
class FindologicController extends FrontendController
{
public function onKernelControllerEvent(ControllerEvent $event): void
{
$this->checkPermission('bundle_ecommerce_back-office_order');

Check failure on line 35 in src/Controller/FindologicController.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, false)

Call to an undefined method Pimcore\Bundle\EcommerceFrameworkBundle\Controller\FindologicController::checkPermission().

Check failure on line 35 in src/Controller/FindologicController.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, 11.x-dev as 11.0.0, true)

Call to an undefined method Pimcore\Bundle\EcommerceFrameworkBundle\Controller\FindologicController::checkPermission().
}

/**
* create xml output for findologic
*/
Expand Down
7 changes: 7 additions & 0 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand All @@ -39,6 +40,12 @@ class IndexController extends UserAwareController
{
use JsonHelperTrait;

public function onKernelControllerEvent(ControllerEvent $event): void
{
$this->checkPermission('bundle_ecommerce_back-office_order');
}


/**
* @Route("/get-filter-groups", name="pimcore_ecommerceframework_index_getfiltergroups", methods={"GET"})
*
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/VoucherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function __construct(TokenStorageUserResolver $tokenStorageUserResolver,

public function onKernelControllerEvent(ControllerEvent $event): void
{
$this->checkPermission('bundle_ecommerce_pricing_rules');

Check failure on line 58 in src/Controller/VoucherController.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, false)

Call to an undefined method Pimcore\Bundle\EcommerceFrameworkBundle\Controller\VoucherController::checkPermission().

Check failure on line 58 in src/Controller/VoucherController.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2, highest, 11.x-dev as 11.0.0, true)

Call to an undefined method Pimcore\Bundle\EcommerceFrameworkBundle\Controller\VoucherController::checkPermission().

// set language
$user = $this->tokenResolver->getUser();

Expand Down

0 comments on commit 2878b3b

Please sign in to comment.