Closed
Description
Symfony version(s) affected
6.3
Description
Always using the default userLoader.
AccessTokenHandler:
readonly class AccessTokenHandler implements AccessTokenHandlerInterface
{
public function __construct(private UserRepository $userRepo, private JWT $jwt)
{
}
public function getUserBadgeFrom(#[\SensitiveParameter] string $accessToken): UserBadge
{
$userId = $this->decodeJWT($accessToken)['id'];
$user = $this->userRepo->find($userId);
return new UserBadge($userId, fn () => $user);
}
....
}
How to reproduce
class UserRepository extends ApiServiceEntityRepository implements PasswordUpgraderInterface, UserLoaderInterface
{
public function loadUserByIdentifier(string|int $identifier): ?User
{
$q = $this->createQueryBuilder('q');
if (is_numeric($identifier)) {
$q->where('q.phone = :identity')->setParameter('identity', (int) $identifier);
} else {
$q->where('q.email = :identity')->setParameter('identity', $identifier);
}
return $q->getQuery()->getOneOrNullResult();
}
....
}
Possible Solution
Before:
if (null === $userBadge->getUserLoader() && $this->userProvider) {
Feature:
#48272
Additional Context
No response