oauth2-server/examples/src/Repositories/UserRepository.php

42 lines
1.4 KiB
PHP
Raw Normal View History

2015-04-05 21:11:10 +01:00
<?php
2016-02-19 18:09:39 -05:00
2015-04-05 21:11:10 +01:00
namespace OAuth2ServerExamples\Repositories;
use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface;
2016-03-22 14:44:39 +00:00
use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface;
2015-04-05 21:11:10 +01:00
use League\OAuth2\Server\Repositories\UserRepositoryInterface;
2016-03-22 14:44:39 +00:00
use OAuth2ServerExamples\Entities\ScopeEntity;
2015-04-05 21:11:10 +01:00
use OAuth2ServerExamples\Entities\UserEntity;
class UserRepository implements UserRepositoryInterface
{
/**
2016-02-19 18:09:39 -05:00
* Get a user entity.
2015-04-05 21:11:10 +01:00
*
* @param string $username
* @param string $password
2016-03-22 11:11:39 -04:00
* @param string $grantType The grant type used
* @param \League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface $clientEntity
* @param ScopeEntityInterface[] $scopes
2015-04-05 21:11:10 +01:00
*
2015-11-16 12:58:50 +00:00
* @return \League\OAuth2\Server\Entities\Interfaces\UserEntityInterface
2015-04-05 21:11:10 +01:00
*/
public function getUserEntityByUserCredentials(
$username,
$password,
$grantType,
ClientEntityInterface $clientEntity,
array &$scopes
) {
2015-11-16 12:58:50 +00:00
if ($username === 'alex' && $password === 'whisky') {
2016-03-22 14:44:39 +00:00
$scope = new ScopeEntity();
$scope->setIdentifier('email');
$scopes[] = $scope;
2015-11-16 12:58:50 +00:00
return new UserEntity();
}
2016-03-22 10:45:28 -04:00
return;
2015-04-05 21:11:10 +01:00
}
}