Updated examples. Fixes #589

This commit is contained in:
Alex Bilbie 2016-06-02 09:35:27 +01:00
parent 78dbb267ed
commit 64a0fcb3a6
2 changed files with 7 additions and 5 deletions

View File

@ -48,6 +48,13 @@ class ScopeRepository implements ScopeRepositoryInterface
ClientEntityInterface $clientEntity, ClientEntityInterface $clientEntity,
$userIdentifier = null $userIdentifier = null
) { ) {
// Example of programatically modifying the final scope of the access token
if ((int) $userIdentifier === 1) {
$scope = new ScopeEntity();
$scope->setIdentifier('email');
$scopes[] = $scope;
}
return $scopes; return $scopes;
} }
} }

View File

@ -11,7 +11,6 @@ namespace OAuth2ServerExamples\Repositories;
use League\OAuth2\Server\Entities\ClientEntityInterface; use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Repositories\UserRepositoryInterface; use League\OAuth2\Server\Repositories\UserRepositoryInterface;
use OAuth2ServerExamples\Entities\ScopeEntity;
use OAuth2ServerExamples\Entities\UserEntity; use OAuth2ServerExamples\Entities\UserEntity;
class UserRepository implements UserRepositoryInterface class UserRepository implements UserRepositoryInterface
@ -26,10 +25,6 @@ class UserRepository implements UserRepositoryInterface
ClientEntityInterface $clientEntity ClientEntityInterface $clientEntity
) { ) {
if ($username === 'alex' && $password === 'whisky') { if ($username === 'alex' && $password === 'whisky') {
$scope = new ScopeEntity();
$scope->setIdentifier('email');
$scopes[] = $scope;
return new UserEntity(); return new UserEntity();
} }