Skip to content

Commit

Permalink
Fix qodana report
Browse files Browse the repository at this point in the history
  • Loading branch information
alexz707 committed Feb 8, 2024
1 parent 83ea88b commit ab52399
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/DependencyInjection/PimcoreStudioApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 14 additions & 7 deletions src/State/ResetPasswordProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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');
}

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit ab52399

Please sign in to comment.