chore(symfony) #57 : bump symfony to version 6.4 and fix deprecations
Some checks are pending
Cadoles/hydra-sql/pipeline/pr-develop Build started...

This commit is contained in:
2025-07-08 17:09:44 +02:00
parent 746ca35b69
commit 2e5e1e72ae
17 changed files with 1127 additions and 1347 deletions

View File

@@ -3,45 +3,48 @@
namespace App\Security;
use App\Entity\User;
use App\Service\SQLLoginService;
use App\SQLLogin\SQLLoginRequest;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
class SQLLoginUserProvider implements UserProviderInterface
{
protected RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
public function __construct(
private readonly RequestStack $requestStack,
private readonly SQLLoginService $sqlLoginService,
private readonly SQLLoginRequest $sqlLoginRequest
){
}
public function loadUserByIdentifier(string $identifier, ?User $user): ?UserInterface
public function loadUserByIdentifier(string $identifier): UserInterface
{
if ($user->getUserIdentifier() === $identifier) {
return $user;
$user = $this->sqlLoginService->fetchPasswordAndDatas($identifier);
$attributes = $user;
unset($attributes[$this->sqlLoginRequest->getPasswordColumnName()]);
if (empty($user[$this->sqlLoginRequest->getLoginColumnName()]) || empty($user[$this->sqlLoginRequest->getPasswordColumnName()])) {
throw new UserNotFoundException('email or password not found');
}
return null;
return new User($user[$this->sqlLoginRequest->getLoginColumnName()], $user[$this->sqlLoginRequest->getPasswordColumnName()], $attributes);
}
public function loadUserByUsername(string $username): ?UserInterface
{
return $this->loadUserByIdentifier($username, null);
}
public function refreshUser(UserInterface $user): UserInterface|null
public function refreshUser(UserInterface $user): UserInterface
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Invalid user class "%s".', get_class($user)));
}
return $this->loadUserByIdentifier($user->getUserIdentifier(), $user);
return $this->loadUserByIdentifier($user->getUserIdentifier());
}
public function supportsClass(string $class): bool
{
return User::class === $class || is_subclass_of($class, User::class);
return User::class === $class || \is_subclass_of($class, User::class);
}
}