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

Appearance settings

Commit 579ed91

Browse filesBrowse files
bug #45463 [Security/Http] Fix getting password-upgrader when user-loader is a closure (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [Security/Http] Fix getting password-upgrader when user-loader is a closure | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Commits ------- b244a06 [Security/Http] Fix getting password-upgrader when user-loader is a closure
2 parents adb7a40 + b244a06 commit 579ed91
Copy full SHA for 579ed91

File tree

2 files changed

+7
-2
lines changed
Filter options

2 files changed

+7
-2
lines changed

‎src/Symfony/Component/Security/Http/EventListener/PasswordMigratingListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/EventListener/PasswordMigratingListener.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public function onLoginSuccess(LoginSuccessEvent $event): void
7979
$userLoader = $userBadge->getUserLoader();
8080
if (\is_array($userLoader) && $userLoader[0] instanceof PasswordUpgraderInterface) {
8181
$passwordUpgrader = $userLoader[0];
82-
} else {
82+
} elseif (!$userLoader instanceof \Closure
83+
|| !($passwordUpgrader = (new \ReflectionFunction($userLoader))->getClosureThis()) instanceof PasswordUpgraderInterface
84+
) {
8385
return;
8486
}
8587
}

‎src/Symfony/Component/Security/Http/Tests/EventListener/PasswordMigratingListenerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/EventListener/PasswordMigratingListenerTest.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,16 @@ public function testUpgradeWithoutUpgrader()
111111
$userLoader = $this->getMockForAbstractClass(TestMigratingUserProvider::class);
112112
$userLoader->expects($this->any())->method('loadUserByIdentifier')->willReturn($this->user);
113113

114-
$userLoader->expects($this->once())
114+
$userLoader->expects($this->exactly(2))
115115
->method('upgradePassword')
116116
->with($this->user, 'new-hash')
117117
;
118118

119119
$event = $this->createEvent(new SelfValidatingPassport(new UserBadge('test', [$userLoader, 'loadUserByIdentifier']), [new PasswordUpgradeBadge('pa$$word')]));
120120
$this->listener->onLoginSuccess($event);
121+
122+
$event = $this->createEvent(new SelfValidatingPassport(new UserBadge('test', \Closure::fromCallable([$userLoader, 'loadUserByIdentifier'])), [new PasswordUpgradeBadge('pa$$word')]));
123+
$this->listener->onLoginSuccess($event);
121124
}
122125

123126
public function testUserWithoutPassword()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.