Skip to content

Commit e4d45fb

Browse files
Merge pull request #42 from thibaut-decherit/fix-password-rehash-on-auth-if-cost-change
fix(password rehash): make sure listener does nothing if event is not...
2 parents f20eff9 + 6a82137 commit e4d45fb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/EventListener/OnAuthPasswordRehashIfAutoEncoderSettingsChange.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Model\AbstractUser;
66
use Doctrine\ORM\EntityManagerInterface;
77
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
8+
use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken;
89
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
910

1011
/**
@@ -66,6 +67,16 @@ public function __construct(
6667
*/
6768
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event): void
6869
{
70+
/*
71+
* onSecurityInteractiveLogin event is fired not only by a successful login (PostAuthenticationGuardToken) but
72+
* also by an authentication through remember me token (RememberMeToken).
73+
* But $event->getRequest()->request->get('password') is obviously empty during the later, thus crashing this
74+
* event listener.
75+
*/
76+
if (get_class($event->getAuthenticationToken()) !== PostAuthenticationGuardToken::class) {
77+
return;
78+
}
79+
6980
/**
7081
* @var AbstractUser $user
7182
*/

0 commit comments

Comments
 (0)