You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #41755 [PasswordHasher] UserPasswordHasher only calls getSalt when method exists (dbrumann)
This PR was squashed before being merged into the 5.3 branch.
Discussion
----------
[PasswordHasher] UserPasswordHasher only calls getSalt when method exists
| Q | A
| ------------- | ---
| Branch? | 5.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix#41753
| License | MIT
Commits
-------
7f9c9d6 [PasswordHasher] UserPasswordHasher only calls getSalt when method exists
Copy file name to clipboardExpand all lines: src/Symfony/Component/PasswordHasher/Hasher/UserPasswordHasher.php
+20-6Lines changed: 20 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,16 @@ public function hashPassword($user, string $plainPassword): string
43
43
trigger_deprecation('symfony/password-hasher', '5.3', 'The "%s()" method expects a "%s" instance as first argument. Not implementing it in class "%s" is deprecated.', __METHOD__, PasswordAuthenticatedUserInterface::class, get_debug_type($user));
44
44
}
45
45
46
-
$salt = $user->getSalt();
47
-
if ($salt && !$userinstanceof LegacyPasswordAuthenticatedUserInterface) {
48
-
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));
46
+
$salt = null;
47
+
48
+
if ($userinstanceof LegacyPasswordAuthenticatedUserInterface) {
49
+
$salt = $user->getSalt();
50
+
} elseif ($userinstanceof UserInterface) {
51
+
$salt = $user->getSalt();
52
+
53
+
if (null !== $salt) {
54
+
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));
@@ -65,9 +72,16 @@ public function isPasswordValid($user, string $plainPassword): bool
65
72
trigger_deprecation('symfony/password-hasher', '5.3', 'The "%s()" method expects a "%s" instance as first argument. Not implementing it in class "%s" is deprecated.', __METHOD__, PasswordAuthenticatedUserInterface::class, get_debug_type($user));
66
73
}
67
74
68
-
$salt = $user->getSalt();
69
-
if ($salt && !$userinstanceof LegacyPasswordAuthenticatedUserInterface) {
70
-
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));
75
+
$salt = null;
76
+
77
+
if ($userinstanceof LegacyPasswordAuthenticatedUserInterface) {
78
+
$salt = $user->getSalt();
79
+
} elseif ($userinstanceof UserInterface) {
80
+
$salt = $user->getSalt();
81
+
82
+
if (null !== $salt) {
83
+
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));
0 commit comments