From ab52399fb3a60ef24f081660d1821977700140a0 Mon Sep 17 00:00:00 2001 From: Alex Zamponi <562324+alexz707@users.noreply.github.com> Date: Thu, 8 Feb 2024 08:55:49 +0100 Subject: [PATCH] Fix qodana report --- .../PimcoreStudioApiExtension.php | 5 ++++- src/State/ResetPasswordProcessor.php | 21 ++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/DependencyInjection/PimcoreStudioApiExtension.php b/src/DependencyInjection/PimcoreStudioApiExtension.php index 85463ac08..6ba89f3b7 100644 --- a/src/DependencyInjection/PimcoreStudioApiExtension.php +++ b/src/DependencyInjection/PimcoreStudioApiExtension.php @@ -51,7 +51,10 @@ public function load(array $configs, ContainerBuilder $container): void } // Pass the configuration to the custom normalizer - $container->setParameter('pimcore_studio_api.serializer.mapping.paths', $config['serializer']['mapping']['paths']); + $container->setParameter( + 'pimcore_studio_api.serializer.mapping.paths', + $config['serializer']['mapping']['paths'] + ); } public function prepend(ContainerBuilder $container): void diff --git a/src/State/ResetPasswordProcessor.php b/src/State/ResetPasswordProcessor.php index 755c95501..b25284f20 100644 --- a/src/State/ResetPasswordProcessor.php +++ b/src/State/ResetPasswordProcessor.php @@ -35,16 +35,20 @@ final class ResetPasswordProcessor implements ProcessorInterface { public function __construct( - private UrlGeneratorInterface $router, - private RequestStack $requestStack, - private RateLimiterFactory $resetPasswordLimiter, - private EventDispatcherInterface $eventDispatcher + private readonly UrlGeneratorInterface $router, + private readonly RequestStack $requestStack, + private readonly RateLimiterFactory $resetPasswordLimiter, + private readonly EventDispatcherInterface $eventDispatcher ) { } public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []) { - if (!$operation instanceof Post || $operation->getUriTemplate() !== '/users/reset-password' || !$data instanceof ResetPasswordRequest) { + if ( + !$operation instanceof Post || + !$data instanceof ResetPasswordRequest || + $operation->getUriTemplate() !== '/users/reset-password' + ) { // wrong operation throw new OperationNotFoundException(); } @@ -57,7 +61,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = $currentRequest = $this->requestStack->getCurrentRequest(); $limiter = $this->resetPasswordLimiter->create($currentRequest->getClientIp()); - if (false === $limiter->consume(1)->isAccepted()) { + if (false === $limiter->consume()->isAccepted()) { throw new InvalidValueException('Rate limit exceeded'); } @@ -102,7 +106,10 @@ public function process(mixed $data, Operation $operation, array $uriVariables = if ($event->getSendMail()) { $mail = Tool::getMail([$user->getEmail()], 'Pimcore lost password service'); $mail->setIgnoreDebugMode(true); - $mail->text("Login to pimcore and change your password using the following link. This temporary login link will expire in 24 hours: \r\n\r\n" . $loginUrl); + $mail->text( + "Login to pimcore and change your password using the following link. ". + "This temporary login link will expire in 24 hours: \r\n\r\n" . $loginUrl + ); $mail->send(); }