[Security] renamed UserProviderInterface::loadUser() to refreshUser()
This commit is contained in:
parent
adb9aaf47d
commit
fa9b920051
@ -9,6 +9,10 @@ timeline closely anyway.
|
||||
beta4 to beta5
|
||||
--------------
|
||||
|
||||
* `UserProviderInterface::loadUser()` has been renamed to
|
||||
`UserProviderInterface::refreshUser()` to make the goal of the method
|
||||
clearer.
|
||||
|
||||
* The `$kernel` property on `WebTestCase` is now static. Change any instances
|
||||
of `$this->kernel` in your functional tests to `self::$kernel`.
|
||||
|
||||
|
@ -50,11 +50,11 @@ class ChainUserProvider implements UserProviderInterface
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadUser(UserInterface $user)
|
||||
public function refreshUser(UserInterface $user)
|
||||
{
|
||||
foreach ($this->providers as $provider) {
|
||||
try {
|
||||
return $provider->loadUser($user);
|
||||
return $provider->refreshUser($user);
|
||||
} catch (UnsupportedUserException $unsupported) {
|
||||
// try next one
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class EntityUserProvider implements UserProviderInterface
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadUser(UserInterface $user)
|
||||
public function refreshUser(UserInterface $user)
|
||||
{
|
||||
if (!$user instanceof $this->class) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
|
||||
|
@ -78,7 +78,7 @@ class InMemoryUserProvider implements UserProviderInterface
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function loadUser(UserInterface $user)
|
||||
public function refreshUser(UserInterface $user)
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
|
||||
|
@ -33,7 +33,7 @@ interface UserProviderInterface
|
||||
function loadUserByUsername($username);
|
||||
|
||||
/**
|
||||
* Loads the user for the account interface.
|
||||
* Refreshes the user for the account interface.
|
||||
*
|
||||
* It is up to the implementation if it decides to reload the user data
|
||||
* from the database, or if it simply merges the passed User into the
|
||||
@ -44,7 +44,7 @@ interface UserProviderInterface
|
||||
*
|
||||
* @return UserInterface
|
||||
*/
|
||||
function loadUser(UserInterface $user);
|
||||
function refreshUser(UserInterface $user);
|
||||
|
||||
/**
|
||||
* Whether this provider supports the given user class
|
||||
|
@ -128,7 +128,7 @@ class ContextListener implements ListenerInterface
|
||||
|
||||
foreach ($this->userProviders as $provider) {
|
||||
try {
|
||||
$token->setUser($provider->loadUser($user));
|
||||
$token->setUser($provider->refreshUser($user));
|
||||
|
||||
if (null !== $this->logger) {
|
||||
$this->logger->debug(sprintf('Username "%s" was reloaded from user provider.', $user->getUsername()));
|
||||
|
@ -66,47 +66,47 @@ class ChainUserProviderTest extends \PHPUnit_Framework_TestCase
|
||||
$provider->loadUserByUsername('foo');
|
||||
}
|
||||
|
||||
public function testloadUser()
|
||||
public function testRefreshUser()
|
||||
{
|
||||
$provider1 = $this->getProvider();
|
||||
$provider1
|
||||
->expects($this->once())
|
||||
->method('loadUser')
|
||||
->method('refreshUser')
|
||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
||||
;
|
||||
|
||||
$provider2 = $this->getProvider();
|
||||
$provider2
|
||||
->expects($this->once())
|
||||
->method('loadUser')
|
||||
->method('refreshUser')
|
||||
->will($this->returnValue($account = $this->getAccount()))
|
||||
;
|
||||
|
||||
$provider = new ChainUserProvider(array($provider1, $provider2));
|
||||
$this->assertSame($account, $provider->loadUser($this->getAccount()));
|
||||
$this->assertSame($account, $provider->refreshUser($this->getAccount()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Security\Core\Exception\UnsupportedUserException
|
||||
*/
|
||||
public function testloadUserThrowsUnsupportedUserException()
|
||||
public function testRefreshUserThrowsUnsupportedUserException()
|
||||
{
|
||||
$provider1 = $this->getProvider();
|
||||
$provider1
|
||||
->expects($this->once())
|
||||
->method('loadUser')
|
||||
->method('refreshUser')
|
||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
||||
;
|
||||
|
||||
$provider2 = $this->getProvider();
|
||||
$provider2
|
||||
->expects($this->once())
|
||||
->method('loadUser')
|
||||
->method('refreshUser')
|
||||
->will($this->throwException(new UnsupportedUserException('unsupported')))
|
||||
;
|
||||
|
||||
$provider = new ChainUserProvider(array($provider1, $provider2));
|
||||
$provider->loadUser($this->getAccount());
|
||||
$provider->refreshUser($this->getAccount());
|
||||
}
|
||||
|
||||
public function testSupportsClass()
|
||||
|
Reference in New Issue
Block a user