Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59f49b2

Browse files
committed
Rename AuthenticatingListener
1 parent60d396f commit59f49b2

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

‎src/Symfony/Bundle/SecurityBundle/Resources/config/security_authenticator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<!-- Listeners-->
4545

46-
<serviceid="Symfony\Component\Security\Http\EventListener\AuthenticatingListener">
46+
<serviceid="security.listener.verify_authenticator_credentials"class="Symfony\Component\Security\Http\EventListener\VerifyAuthenticatorCredentialsListener">
4747
<tagname="kernel.event_subscriber" />
4848
<argumenttype="service"id="security.encoder_factory" />
4949
</service>

‎src/Symfony/Component/Security/Http/EventListener/AuthenticatingListener.phprenamed to‎src/Symfony/Component/Security/Http/EventListener/VerifyAuthenticatorCredentialsListener.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
useSymfony\Component\EventDispatcher\EventSubscriberInterface;
66
useSymfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
7+
useSymfony\Component\Security\Core\Exception\BadCredentialsException;
78
useSymfony\Component\Security\Core\Exception\LogicException;
89
useSymfony\Component\Security\Http\Authenticator\CustomAuthenticatedInterface;
910
useSymfony\Component\Security\Http\Authenticator\PasswordAuthenticatedInterface;
@@ -19,7 +20,7 @@
1920
* @final
2021
* @experimental in 5.1
2122
*/
22-
classAuthenticatingListenerimplements EventSubscriberInterface
23+
classVerifyAuthenticatorCredentialsListenerimplements EventSubscriberInterface
2324
{
2425
private$encoderFactory;
2526

@@ -28,22 +29,22 @@ public function __construct(EncoderFactoryInterface $encoderFactory)
2829
$this->encoderFactory =$encoderFactory;
2930
}
3031

31-
publicstaticfunctiongetSubscribedEvents():array
32-
{
33-
return [VerifyAuthenticatorCredentialsEvent::class => ['onAuthenticating',128]];
34-
}
35-
3632
publicfunctiononAuthenticating(VerifyAuthenticatorCredentialsEvent$event):void
3733
{
3834
$authenticator =$event->getAuthenticator();
3935
if ($authenticatorinstanceof PasswordAuthenticatedInterface) {
4036
// Use the password encoder to validate the credentials
4137
$user =$event->getUser();
42-
$event->setCredentialsValid($this->encoderFactory->getEncoder($user)->isPasswordValid(
43-
$user->getPassword(),
44-
$authenticator->getPassword($event->getCredentials()),
45-
$user->getSalt()
46-
));
38+
$presentedPassword =$authenticator->getPassword($event->getCredentials());
39+
if ('' ===$presentedPassword) {
40+
thrownewBadCredentialsException('The presented password cannot be empty.');
41+
}
42+
43+
if (null ===$user->getPassword()) {
44+
return;
45+
}
46+
47+
$event->setCredentialsValid($this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(),$presentedPassword,$user->getSalt()));
4748

4849
return;
4950
}
@@ -65,4 +66,9 @@ public function onAuthenticating(VerifyAuthenticatorCredentialsEvent $event): vo
6566

6667
thrownewLogicException(sprintf('Authenticator %s does not have valid credentials. Authenticators must implement one of the authenticated interfaces (%s, %s or %s).',\get_class($authenticator), PasswordAuthenticatedInterface::class, TokenAuthenticatedInterface::class, CustomAuthenticatedInterface::class));
6768
}
69+
70+
publicstaticfunctiongetSubscribedEvents():array
71+
{
72+
return [VerifyAuthenticatorCredentialsEvent::class => ['onAuthenticating',128]];
73+
}
6874
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp