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 5ca9403

Browse filesBrowse files
committed
Prepare PasswordUpgraderInterface implementations for 6.0 signatures
1 parent 64b09eb commit 5ca9403
Copy full SHA for 5ca9403

File tree

5 files changed

+17
-9
lines changed
Filter options

5 files changed

+17
-9
lines changed

‎src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ public function supportsClass(string $class)
133133
*
134134
* @final
135135
*/
136-
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
136+
public function upgradePassword($user, string $newHashedPassword): void
137137
{
138138
if (!$user instanceof PasswordAuthenticatedUserInterface) {
139139
trigger_deprecation('symfony/doctrine-bridge', '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));
140+
141+
if (!$user instanceof UserInterface) {
142+
throw new \TypeError(sprintf('The "%s::upgradePassword()" method expects an instance of "%s" as first argument, "%s" given.', PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
143+
}
140144
}
141145

142146
$class = $this->getClass();
@@ -146,7 +150,7 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)
146150

147151
$repository = $this->getRepository();
148152
if ($repository instanceof PasswordUpgraderInterface) {
149-
$repository->upgradePassword($user, $newEncodedPassword);
153+
$repository->upgradePassword($user, $newHashedPassword);
150154
}
151155
}
152156

‎src/Symfony/Component/Ldap/Security/LdapUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Ldap/Security/LdapUserProvider.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function refreshUser(UserInterface $user)
132132
*
133133
* @final
134134
*/
135-
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
135+
public function upgradePassword($user, string $newHashedPassword): void
136136
{
137137
if (!$user instanceof LdapUser) {
138138
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
@@ -143,9 +143,9 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)
143143
}
144144

145145
try {
146-
$user->getEntry()->setAttribute($this->passwordAttribute, [$newEncodedPassword]);
146+
$user->getEntry()->setAttribute($this->passwordAttribute, [$newHashedPassword]);
147147
$this->ldap->getEntryManager()->update($user->getEntry());
148-
$user->setPassword($newEncodedPassword);
148+
$user->setPassword($newHashedPassword);
149149
} catch (ExceptionInterface $e) {
150150
// ignore failed password upgrades
151151
}

‎src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php
+1-1Lines 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
}

‎src/Symfony/Component/Security/Core/User/ChainUserProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/User/ChainUserProvider.php
+6-2Lines 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
}

‎src/Symfony/Component/Security/Http/Tests/Authenticator/Fixtures/PasswordUpgraderProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Http/Tests/Authenticator/Fixtures/PasswordUpgraderProvider.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class PasswordUpgraderProvider extends InMemoryUserProvider implements PasswordUpgraderInterface
2020
{
21-
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
21+
public function upgradePassword($user, string $newHashedPassword): void
2222
{
2323
}
2424
}

0 commit comments

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