mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 17:56:14 +05:30
Added PasswordGrantProvider
This commit is contained in:
parent
b5bbf8332f
commit
d3ed454881
37
src/ServiceProviders/PasswordGrantProvider.php
Normal file
37
src/ServiceProviders/PasswordGrantProvider.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace League\OAuth2\Server\ServiceProviders;
|
||||||
|
|
||||||
|
use League\Container\ServiceProvider;
|
||||||
|
use League\OAuth2\Server\Grant\PasswordGrant;
|
||||||
|
|
||||||
|
class PasswordGrantProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
protected $provides = ['PasswordGrant'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$container = $this->getContainer();
|
||||||
|
|
||||||
|
$container->add('PasswordGrant', function () use ($container) {
|
||||||
|
|
||||||
|
$refreshTokenRepository = null;
|
||||||
|
if ($container->isRegistered('RefreshTokenRepository')) {
|
||||||
|
$refreshTokenRepository = $container->get('RefreshTokenRepository');
|
||||||
|
}
|
||||||
|
|
||||||
|
$grant = new PasswordGrant(
|
||||||
|
$container->get('emitter'),
|
||||||
|
$container->get('ClientRepository'),
|
||||||
|
$container->get('ScopeRepository'),
|
||||||
|
$container->get('AccessTokenRepository'),
|
||||||
|
$container->get('UserRepository'),
|
||||||
|
$refreshTokenRepository
|
||||||
|
);
|
||||||
|
return $grant;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user