Skip to content

Commit

Permalink
Merge pull request #6 from mapbender/fix/user-exception
Browse files Browse the repository at this point in the history
Fix/user exception
  • Loading branch information
PhilVanB committed Jul 8, 2024
2 parents 60705b2 + 9cfa093 commit b575ddc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v2.0.2
* Replace UsernameNotFoundException with new UserNotFoundException

## v2.0.1
* Change to ldap_search function instead of ldap_list

Expand Down
6 changes: 3 additions & 3 deletions Security/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Symfony\Component\Ldap\Adapter\QueryInterface;
use Symfony\Component\Ldap\Entry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Mapbender\LDAPBundle\Security\LdapClient;
Expand Down Expand Up @@ -65,7 +65,7 @@ public function loadUserByIdentifier(string $username): UserInterface
// skips to the next provider, if any
/** @see \Symfony\Component\Security\Core\User\ChainUserProvider::loadUserByUsername() */
if (!$this->client->getHost()) {
throw new UsernameNotFoundException('LDAP lookup disabled with empty host configuration', 0);
throw new UserNotFoundException('LDAP lookup disabled with empty host configuration', 0);
}

$this->client->bind();
Expand All @@ -76,7 +76,7 @@ public function loadUserByIdentifier(string $username): UserInterface
$roles = $this->findLdapUserRoles($results[0]);
return new LdapUser($username, $roles);
} else {
throw new UsernameNotFoundException(sprintf('User "%s" could not be fetched from LDAP.', $username), 0);
throw new UserNotFoundException(sprintf('User "%s" could not be fetched from LDAP.', $username), 0);
}
}

Expand Down

0 comments on commit b575ddc

Please sign in to comment.