Add additional repository

This commit is contained in:
Alex Bilbie 2016-03-22 14:44:39 +00:00
parent e27b13ee7d
commit ed17b6540e

View File

@ -2,25 +2,34 @@
namespace OAuth2ServerExamples\Repositories; namespace OAuth2ServerExamples\Repositories;
use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface;
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
{ {
/** /**
* Get a user entity. * Get a user entity.
* *
* @param string $username * @param string $username
* @param string $password * @param string $password
* @param string $grantType The grant type used
* @param ScopeEntityInterface[] $scopes
* *
* @return \League\OAuth2\Server\Entities\Interfaces\UserEntityInterface * @return \League\OAuth2\Server\Entities\Interfaces\UserEntityInterface
*/ */
public function getUserEntityByUserCredentials($username, $password) public function getUserEntityByUserCredentials($username, $password, $grantType, array &$scopes)
{ {
if ($username === 'alex' && $password === 'whisky') { if ($username === 'alex' && $password === 'whisky') {
$scope = new ScopeEntity();
$scope->setIdentifier('email');
$scopes[] = $scope;
return new UserEntity(); return new UserEntity();
} }
return; return null;
} }
} }