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

36 lines
1.0 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;
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-03-22 14:44:39 +00:00
2015-04-05 21:11:10 +01:00
/**
2016-02-19 18:09:39 -05:00
* Get a user entity.
2015-04-05 21:11:10 +01:00
*
2016-03-22 14:44:39 +00:00
* @param string $username
* @param string $password
* @param string $grantType The grant type used
* @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
*/
2016-03-22 14:44:39 +00:00
public function getUserEntityByUserCredentials($username, $password, $grantType, array &$scopes)
2015-04-05 21:11:10 +01:00
{
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 14:44:39 +00:00
return null;
2015-04-05 21:11:10 +01:00
}
}