class CheckCredentialsListener implements EventSubscriberInterface
{ private PasswordHasherFactoryInterface
$hasherFactory;
public function __construct(PasswordHasherFactoryInterface
$hasherFactory) { $this->hasherFactory =
$hasherFactory;
} public function checkPassport(CheckPassportEvent
$event): void
{ $passport =
$event->
getPassport();
if ($passport->
hasBadge(PasswordCredentials::
class)) { // Use the password hasher to validate the credentials
$user =
$passport->
getUser();
if (!
$user instanceof PasswordAuthenticatedUserInterface
) { throw new \
LogicException(sprintf('Class "%s" must implement "%s" for using password-based authentication.',
get_debug_type($user), PasswordAuthenticatedUserInterface::
class));
} /** @var PasswordCredentials $badge */
$badge =
$passport->
getBadge(PasswordCredentials::
class);