Skip to content

Commit 95503e3

Browse files
committed
Prepare PasswordUpgraderInterface implementations for 6.0 signatures
1 parent bdc2aac commit 95503e3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public function eraseCredentials()
384384
}
385385
interface PasswordUpgraderProvider extends UserProviderInterface, PasswordUpgraderInterface
386386
{
387-
public function upgradePassword(UserInterface $user, string $newHashedPassword): void;
387+
public function upgradePassword($user, string $newHashedPassword): void;
388388

389389
public function loadUserByIdentifier(string $identifier): UserInterface;
390390
}

User/ChainUserProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,20 @@ public function supportsClass(string $class)
130130
*
131131
* {@inheritdoc}
132132
*/
133-
public function upgradePassword($user, string $newEncodedPassword): void
133+
public function upgradePassword($user, string $newHashedPassword): void
134134
{
135135
if (!$user instanceof PasswordAuthenticatedUserInterface) {
136136
trigger_deprecation('symfony/security-core', '5.3', 'The "%s::upgradePassword()" method expects an instance of "%s" as first argument, the "%s" class should implement it.', PasswordUpgraderInterface::class, PasswordAuthenticatedUserInterface::class, get_debug_type($user));
137+
138+
if (!$user instanceof UserInterface) {
139+
throw new \TypeError(sprintf('The "%s::upgradePassword()" method expects an instance of "%s" as first argument, "%s" given.', PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
140+
}
137141
}
138142

139143
foreach ($this->providers as $provider) {
140144
if ($provider instanceof PasswordUpgraderInterface) {
141145
try {
142-
$provider->upgradePassword($user, $newEncodedPassword);
146+
$provider->upgradePassword($user, $newHashedPassword);
143147
} catch (UnsupportedUserException $e) {
144148
// ignore: password upgrades are opportunistic
145149
}

0 commit comments

Comments
 (0)