mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
refactor: use Dto class instead of array
This commit is contained in:
@@ -14,7 +14,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
use Symfony\Component\Serializer\Exception\ExceptionInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
|
||||||
|
|
||||||
class ConnectorController extends AbstractController
|
class ConnectorController extends AbstractController
|
||||||
{
|
{
|
||||||
@@ -23,7 +22,6 @@ class ConnectorController extends AbstractController
|
|||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
#[Autowire(service: 'service_container')]
|
#[Autowire(service: 'service_container')]
|
||||||
private readonly ContainerInterface $locator,
|
private readonly ContainerInterface $locator,
|
||||||
private readonly NormalizerInterface $normalizer,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,11 +74,7 @@ class ConnectorController extends AbstractController
|
|||||||
|
|
||||||
/** @var AbstractProvider $providerClient */
|
/** @var AbstractProvider $providerClient */
|
||||||
$providerClient = $this->locator->get($provider->getConnectorProvider());
|
$providerClient = $this->locator->get($provider->getConnectorProvider());
|
||||||
$authData = $this->normalizer->normalize($providerClient->authenticate($connector->getAuthData()), 'json');
|
$connector->setAuthData($providerClient->authenticate($connector->getAuthData()));
|
||||||
if (!is_array($authData)) {
|
|
||||||
throw new BadRequestHttpException('Authentication data cannot be normalized.');
|
|
||||||
}
|
|
||||||
$connector->setAuthData((array) $authData);
|
|
||||||
|
|
||||||
$this->logger->info('User {username} authentication data with the {provider} provider has been validated.', [
|
$this->logger->info('User {username} authentication data with the {provider} provider has been validated.', [
|
||||||
'username' => $user->getUserIdentifier(),
|
'username' => $user->getUserIdentifier(),
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Service\Connector;
|
|||||||
|
|
||||||
use App\Dto\Connector\DefaultProviderDto;
|
use App\Dto\Connector\DefaultProviderDto;
|
||||||
use App\Entity\Domain;
|
use App\Entity\Domain;
|
||||||
use Exception;
|
|
||||||
use Psr\Cache\CacheItemInterface;
|
use Psr\Cache\CacheItemInterface;
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
|
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
|
||||||
@@ -127,12 +126,12 @@ abstract class AbstractProvider
|
|||||||
* @throws ExceptionInterface
|
* @throws ExceptionInterface
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function authenticate(array $authData): DefaultProviderDto
|
public function authenticate(array $authData): array
|
||||||
{
|
{
|
||||||
$this->authData = $this->verifyAuthData($authData);
|
$this->authData = $this->verifyAuthData($authData);
|
||||||
$this->assertAuthentication();
|
$this->assertAuthentication();
|
||||||
|
|
||||||
return $this->authData;
|
return $authData;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function getCachedTldList(): CacheItemInterface;
|
abstract protected function getCachedTldList(): CacheItemInterface;
|
||||||
|
|||||||
Reference in New Issue
Block a user