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