10000 fixup! [Security] Fixed auth provider authenticate() cannot return void · symfony/symfony@8eabff8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8eabff8

Browse files
committed
fixup! [Security] Fixed auth provider authenticate() cannot return void
1 parent ecedb61 commit 8eabff8

8 files changed

+15
-8
lines changed

src/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Security\Core\Authentication\Provider;
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
15+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1516
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1617
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
1718

@@ -38,7 +39,7 @@ public function __construct($key)
3839
public function authenticate(TokenInterface $token)
3940
{
4041
if (!$this->supports($token)) {
41-
throw new BadCredentialsException('The token is not supported by this authentication provider.');
42+
throw new AuthenticationException('The token is not supported by this authentication provider.');
4243
}
4344

4445
if ($this->key !== $token->getKey()) {

src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\User\UserProviderInterface;
1515
use Symfony\Component\Security\Core\User\UserCheckerInterface;
16+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1617
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1718
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
1819
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -51,7 +52,7 @@ public function __construct(UserProviderInterface $userProvider, UserCheckerInte
5152
public function authenticate(TokenInterface $token)
5253
{
5354
if (!$this->supports($token)) {
54-
throw new BadCredentialsException('The token is not supported by this authentication provider.');
55+
throw new AuthenticationException('The token is not supported by this authentication provider.');
5556
}
5657

5758
if (!$user = $token->getUser()) {

src/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Security\Core\User\UserCheckerInterface;
1515
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1616
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
17+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1718
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1819

1920
class RememberMeAuthenticationProvider implements AuthenticationProviderInterface
@@ -40,7 +41,7 @@ public function __construct(UserCheckerInterface $userChecker, $key, $providerKe
4041
public function authenticate(TokenInterface $token)
4142
{
4243
if (!$this->supports($token)) {
43-
throw new BadCredentialsException('The token is not supported by this authentication provider.');
44+
throw new AuthenticationException('The token is not supported by this authentication provider.');
4445
}
4546

4647
if ($this->key !== $token->getKey()) {

src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(UserCheckerInterface $userChecker, $providerKey, $hi
5656
public function authenticate(TokenInterface $token)
5757
{
5858
if (!$this->supports($token)) {
59-
throw new BadCredentialsException('The token is not supported by this authentication provider.');
59+
throw new AuthenticationException('The token is not supported by this authentication provider.');
6060
}
6161

6262
$username = $token->getUsername();

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public function testSupports()
2525
}
2626

2727
/**
28-
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
28+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
29+
* @expectedExceptionMessage The token is not supported by this authentication provider.
2930
*/
3031
public function testAuthenticateWhenTokenIsNotSupported()
3132
{

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ public function testSupports()
3737
}
3838

3939
/**
40-
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
40+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
41+
* @expectedExceptionMessage The token is not supported by this authentication provider.
4142
*/
4243
public function testAuthenticateWhenTokenIsNotSupported()
4344
{

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public function testSupports()
2727
}
2828

2929
/**
30-
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
30+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
31+
* @expectedExceptionMessage The token is not supported by this authentication provider.
3132
*/
3233
public function testAuthenticateWhenTokenIsNotSupported()
3334
{

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public function testSupports()
3030
}
3131

3232
/**
33-
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
33+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
34+
* @expectedExceptionMessage The token is not supported by this authentication provider.
3435
*/
3536
public function testAuthenticateWhenTokenIsNotSupported()
3637
{

0 commit comments

Comments
 (0)
0