Skip to content

Commit dabfa59

Browse files
bug symfony#61194 [Security] Fix added $token argument to UserCheckerInterface::checkPostAuth() (nicolas-grekas)
This PR was merged into the 7.2 branch. Discussion ---------- [Security] Fix added $token argument to UserCheckerInterface::checkPostAuth() | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT An added argument must be optional and must be declared using ``@param``, which will allow spotting all places that have to be updated in cascade. This PR fixes all that. Not sure how we messed up so badly in symfony#57773 😅 Commits ------- c819110 [Security] Fix added $token argument to UserCheckerInterface::checkPostAuth()
2 parents 255c0ae + c819110 commit dabfa59

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ public function checkPreAuth(UserInterface $user): void
986986
{
987987
}
988988

989-
public function checkPostAuth(UserInterface $user): void
989+
public function checkPostAuth(UserInterface $user, ?TokenInterface $token = null): void
990990
{
991991
}
992992
}

src/Symfony/Component/Security/Core/User/ChainUserChecker.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ public function checkPreAuth(UserInterface $user): void
2929
}
3030
}
3131

32-
public function checkPostAuth(UserInterface $user /* , TokenInterface $token */): void
32+
/**
33+
* @param ?TokenInterface $token
34+
*/
35+
public function checkPostAuth(UserInterface $user /* , ?TokenInterface $token = null */): void
3336
{
3437
$token = 1 < \func_num_args() ? func_get_arg(1) : null;
3538

3639
foreach ($this->checkers as $checker) {
37-
if ($token instanceof TokenInterface) {
38-
$checker->checkPostAuth($user, $token);
39-
} else {
40-
$checker->checkPostAuth($user);
41-
}
40+
$checker->checkPostAuth($user, $token);
4241
}
4342
}
4443
}

src/Symfony/Component/Security/Core/User/InMemoryUserChecker.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ public function checkPreAuth(UserInterface $user): void
3333
}
3434
}
3535

36-
public function checkPostAuth(UserInterface $user): void
36+
/**
37+
* @param ?TokenInterface $token
38+
*/
39+
public function checkPostAuth(UserInterface $user /* , ?TokenInterface $token = null */): void
3740
{
3841
}
3942
}

src/Symfony/Component/Security/Core/User/UserCheckerInterface.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\User;
1313

14+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1415
use Symfony\Component\Security\Core\Exception\AccountStatusException;
1516

1617
/**
@@ -33,7 +34,9 @@ public function checkPreAuth(UserInterface $user): void;
3334
/**
3435
* Checks the user account after authentication.
3536
*
37+
* @param ?TokenInterface $token
38+
*
3639
* @throws AccountStatusException
3740
*/
38-
public function checkPostAuth(UserInterface $user /* , TokenInterface $token */): void;
41+
public function checkPostAuth(UserInterface $user /* , ?TokenInterface $token = null */): void;
3942
}

0 commit comments

Comments
 (0)