Skip to content

Commit

Permalink
判断基準をUserInterfaceへ変更
Browse files Browse the repository at this point in the history
  • Loading branch information
shinya committed Sep 28, 2023
1 parent 41da667 commit 9eece6d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Eccube/EventListener/RateLimiterListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\RateLimiter\RateLimiterFactory;
use Symfony\Component\Security\Core\User\UserInterface;

class RateLimiterListener implements EventSubscriberInterface
{
Expand Down Expand Up @@ -50,7 +51,6 @@ public function onController(ControllerEvent $event)
if (!isset($limiterConfigs[$route])) {
return;
}

$method = $request->getMethod();

foreach ($limiterConfigs[$route] as $id => $config) {
Expand All @@ -75,12 +75,11 @@ public function onController(ControllerEvent $event)
if (!$this->locator->has($limiterId)) {
continue;
}

/** @var RateLimiterFactory $factory */
$factory = $this->locator->get($limiterId);
if (in_array('customer', $config['type']) || in_array('user', $config['type'])) {
$User = $this->requestContext->getCurrentUser();
if ($User instanceof Customer || $User instanceof Member) {
if ($User instanceof UserInterface) {
$limiter = $factory->create($User->getId());
if (!$limiter->consume()->isAccepted()) {
throw new TooManyRequestsHttpException();
Expand Down

0 comments on commit 9eece6d

Please sign in to comment.