Skip to content

Commit 05dfbdb

Browse files
committed
minor symfony#16635 [Security] add USERNAME_NONE_PROVIDED constant (SofHad)
This PR was submitted for the 2.8 branch but it was merged into the 3.1-dev branch instead (closes symfony#16635). Discussion ---------- [Security] add USERNAME_NONE_PROVIDED constant | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | no I think that is better if we use a constant to define this string. Commits ------- 3f60598 [Security] add USERNAME_NONE_PROVIDED constant
2 parents 0974606 + 3f60598 commit 05dfbdb

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
*/
2525
interface AuthenticationProviderInterface extends AuthenticationManagerInterface
2626
{
27+
/**
28+
* Use this constant for not provided username
29+
*
30+
* @var string
31+
*/
32+
const USERNAME_NONE_PROVIDED = 'NONE_PROVIDED';
33+
2734
/**
2835
* Checks whether this provider supports the given token.
2936
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(UserProviderInterface $userProvider, UserCheckerInte
5858
*/
5959
protected function retrieveUser($username, UsernamePasswordToken $token)
6060
{
61-
if ('NONE_PROVIDED' === $username) {
61+
if (AuthenticationProviderInterface::USERNAME_NONE_PROVIDED === $username) {
6262
throw new UsernameNotFoundException('Username can not be null');
6363
}
6464

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function authenticate(TokenInterface $token)
6363

6464
$username = $token->getUsername();
6565
if ('' === $username || null === $username) {
66-
$username = 'NONE_PROVIDED';
66+
$username = AuthenticationProviderInterface::USERNAME_NONE_PROVIDED;
6767
}
6868

6969
try {

0 commit comments

Comments
 (0)