summaryrefslogtreecommitdiffstats
path: root/Core/User
diff options
context:
space:
mode:
Diffstat (limited to 'Core/User')
-rw-r--r--Core/User/ChainUserProvider.php8
-rw-r--r--Core/User/InMemoryUserProvider.php7
-rw-r--r--Core/User/UserChecker.php16
3 files changed, 24 insertions, 7 deletions
diff --git a/Core/User/ChainUserProvider.php b/Core/User/ChainUserProvider.php
index 376ba1c..3ff1ea9 100644
--- a/Core/User/ChainUserProvider.php
+++ b/Core/User/ChainUserProvider.php
@@ -44,7 +44,9 @@ class ChainUserProvider implements UserProviderInterface
}
}
- throw new UsernameNotFoundException(sprintf('There is no user with name "%s".', $username));
+ $ex = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $username));
+ $ex->setUsername($username);
+ throw $ex;
}
/**
@@ -66,7 +68,9 @@ class ChainUserProvider implements UserProviderInterface
}
if ($supportedUserFound) {
- throw new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
+ $ex = new UsernameNotFoundException(sprintf('There is no user with name "%s".', $user->getUsername()));
+ $ex->setUsername($user->getUsername());
+ throw $ex;
} else {
throw new UnsupportedUserException(sprintf('The account "%s" is not supported.', get_class($user)));
}
diff --git a/Core/User/InMemoryUserProvider.php b/Core/User/InMemoryUserProvider.php
index eae2083..e87f80c 100644
--- a/Core/User/InMemoryUserProvider.php
+++ b/Core/User/InMemoryUserProvider.php
@@ -50,6 +50,8 @@ class InMemoryUserProvider implements UserProviderInterface
* Adds a new User to the provider.
*
* @param UserInterface $user A UserInterface instance
+ *
+ * @throws \LogicException
*/
public function createUser(UserInterface $user)
{
@@ -66,7 +68,10 @@ class InMemoryUserProvider implements UserProviderInterface
public function loadUserByUsername($username)
{
if (!isset($this->users[strtolower($username)])) {
- throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
+ $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
+ $ex->setUsername($username);
+
+ throw $ex;
}
$user = $this->users[strtolower($username)];
diff --git a/Core/User/UserChecker.php b/Core/User/UserChecker.php
index 93897a1..8dde3a6 100644
--- a/Core/User/UserChecker.php
+++ b/Core/User/UserChecker.php
@@ -33,7 +33,9 @@ class UserChecker implements UserCheckerInterface
}
if (!$user->isCredentialsNonExpired()) {
- throw new CredentialsExpiredException('User credentials have expired.', $user);
+ $ex = new CredentialsExpiredException('User credentials have expired.');
+ $ex->setUser($user);
+ throw $ex;
}
}
@@ -47,15 +49,21 @@ class UserChecker implements UserCheckerInterface
}
if (!$user->isAccountNonLocked()) {
- throw new LockedException('User account is locked.', $user);
+ $ex = new LockedException('User account is locked.');
+ $ex->setUser($user);
+ throw $ex;
}
if (!$user->isEnabled()) {
- throw new DisabledException('User account is disabled.', $user);
+ $ex = new DisabledException('User account is disabled.');
+ $ex->setUser($user);
+ throw $ex;
}
if (!$user->isAccountNonExpired()) {
- throw new AccountExpiredException('User account has expired.', $user);
+ $ex = new AccountExpiredException('User account has expired.');
+ $ex->setUser($user);
+ throw $ex;
}
}
}