Revert "Remove redundant parameters in example"

This reverts commit 9a93dca05c.
This commit is contained in:
Alex Bilbie 2016-05-04 09:07:50 +01:00
parent cf63403585
commit d1bc4848c8
3 changed files with 16 additions and 4 deletions

View File

@ -43,8 +43,15 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getNewToken() public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null)
{ {
return new AccessTokenEntity(); $accessToken = new AccessTokenEntity();
$accessToken->setClient($clientEntity);
foreach ($scopes as $scope) {
$accessToken->addScope($scope);
}
$accessToken->setUserIdentifier($userIdentifier);
return $accessToken;
} }
} }

View File

@ -295,7 +295,7 @@ abstract class AbstractGrant implements GrantTypeInterface
$userIdentifier, $userIdentifier,
array $scopes = [] array $scopes = []
) { ) {
$accessToken = $this->accessTokenRepository->getNewToken(); $accessToken = $this->accessTokenRepository->getNewToken($client, $scopes, $userIdentifier);
$accessToken->setClient($client); $accessToken->setClient($client);
$accessToken->setUserIdentifier($userIdentifier); $accessToken->setUserIdentifier($userIdentifier);
$accessToken->setIdentifier($this->generateUniqueIdentifier()); $accessToken->setIdentifier($this->generateUniqueIdentifier());

View File

@ -10,6 +10,7 @@
namespace League\OAuth2\Server\Repositories; namespace League\OAuth2\Server\Repositories;
use League\OAuth2\Server\Entities\AccessTokenEntityInterface; use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
use League\OAuth2\Server\Entities\ClientEntityInterface;
/** /**
* Access token interface. * Access token interface.
@ -19,9 +20,13 @@ interface AccessTokenRepositoryInterface extends RepositoryInterface
/** /**
* Create a new access token * Create a new access token
* *
* @param \League\OAuth2\Server\Entities\ClientEntityInterface $clientEntity
* @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
* @param mixed $userIdentifier
*
* @return AccessTokenEntityInterface * @return AccessTokenEntityInterface
*/ */
public function getNewToken(); public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null);
/** /**
* Persists a new access token to permanent storage. * Persists a new access token to permanent storage.