From d1bc4848c8a006ebc82cba9e391c141e578bb813 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 4 May 2016 09:07:50 +0100 Subject: [PATCH] Revert "Remove redundant parameters in example" This reverts commit 9a93dca05c4240ccc6a9bb99151b702ae5872263. --- examples/src/Repositories/AccessTokenRepository.php | 11 +++++++++-- src/Grant/AbstractGrant.php | 2 +- src/Repositories/AccessTokenRepositoryInterface.php | 7 ++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/src/Repositories/AccessTokenRepository.php b/examples/src/Repositories/AccessTokenRepository.php index 12386f2c..d7736c76 100644 --- a/examples/src/Repositories/AccessTokenRepository.php +++ b/examples/src/Repositories/AccessTokenRepository.php @@ -43,8 +43,15 @@ class AccessTokenRepository implements AccessTokenRepositoryInterface /** * {@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; } } diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 45c8fc2a..9c72a9a1 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -295,7 +295,7 @@ abstract class AbstractGrant implements GrantTypeInterface $userIdentifier, array $scopes = [] ) { - $accessToken = $this->accessTokenRepository->getNewToken(); + $accessToken = $this->accessTokenRepository->getNewToken($client, $scopes, $userIdentifier); $accessToken->setClient($client); $accessToken->setUserIdentifier($userIdentifier); $accessToken->setIdentifier($this->generateUniqueIdentifier()); diff --git a/src/Repositories/AccessTokenRepositoryInterface.php b/src/Repositories/AccessTokenRepositoryInterface.php index a3293344..aab8eab8 100644 --- a/src/Repositories/AccessTokenRepositoryInterface.php +++ b/src/Repositories/AccessTokenRepositoryInterface.php @@ -10,6 +10,7 @@ namespace League\OAuth2\Server\Repositories; use League\OAuth2\Server\Entities\AccessTokenEntityInterface; +use League\OAuth2\Server\Entities\ClientEntityInterface; /** * Access token interface. @@ -19,9 +20,13 @@ interface AccessTokenRepositoryInterface extends RepositoryInterface /** * Create a new access token * + * @param \League\OAuth2\Server\Entities\ClientEntityInterface $clientEntity + * @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes + * @param mixed $userIdentifier + * * @return AccessTokenEntityInterface */ - public function getNewToken(); + public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null); /** * Persists a new access token to permanent storage.