Skip to content

Commit d288f51

Browse files
committed
[Security] fix check for empty usernames
1 parent 309fca4 commit d288f51

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

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

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)) {

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)