Skip to content

Commit 6585fe4

Browse files
committed
[Security] fix check for empty usernames
1 parent 510b2d2 commit 6585fe4

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

src/Symfony/Component/Security/Acl/Domain/UserSecurityIdentity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class UserSecurityIdentity implements SecurityIdentityInterface
3636
*/
3737
public function __construct($username, $class)
3838
{
39-
if (empty($username)) {
39+
if ('' === $username || null === $username) {
4040
throw new \InvalidArgumentException('$username must not be empty.');
4141
}
4242
if (empty($class)) {

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

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

6464
$username = $token->getUsername();
65-
if (empty($username)) {
65+
if ('' === $username || null === $username) {
6666
$username = 'NONE_PROVIDED';
6767
}
6868

src/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct($class, $username, $series, $tokenValue, \DateTime $
4040
if (empty($class)) {
4141
throw new \InvalidArgumentException('$class must not be empty.');
4242
}
43-
if (empty($username)) {
43+
if ('' === $username || null === $username) {
4444
throw new \InvalidArgumentException('$username must not be empty.');
4545
}
4646
if (empty($series)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class User implements AdvancedUserInterface
3030

3131
public function __construct($username, $password, array $roles = array(), $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
3232
{
33-
if (empty($username)) {
33+
if ('' === $username || null === $username) {
3434
throw new \InvalidArgumentException('The username cannot be empty.');
3535
}
3636

0 commit comments

Comments
 (0)