mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 10:41:51 +05:30
Added verify credentials callback
This commit is contained in:
parent
0a260f0c8c
commit
324da27ea9
@ -27,16 +27,21 @@ $server->setAuthCodeStorage(new Storage\AuthCodeStorage);
|
||||
|
||||
$clientCredentials = new \League\OAuth2\Server\Grant\ClientCredentialsGrant();
|
||||
$server->addGrantType($clientCredentials);
|
||||
|
||||
$passwordGrant = new \League\OAuth2\Server\Grant\PasswordGrant();
|
||||
$passwordGrant->setVerifyCredentialsCallback(function ($username, $password) {
|
||||
$result = (new Model\Users())->get($username);
|
||||
if (count($result) !== 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (password_verify($password, $result[0]['password'])) {
|
||||
return $username;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
$server->addGrantType($passwordGrant);
|
||||
$refrehTokenGrant = new \League\OAuth2\Server\Grant\RefreshTokenGrant();
|
||||
$server->addGrantType($refrehTokenGrant);
|
||||
$clientCredentials = new \League\OAuth2\Server\Grant\ClientCredentialsGrant();
|
||||
$server->addGrantType($clientCredentials);
|
||||
$passwordGrant = new \League\OAuth2\Server\Grant\PasswordGrant();
|
||||
$server->addGrantType($passwordGrant);
|
||||
$refrehTokenGrant = new \League\OAuth2\Server\Grant\RefreshTokenGrant();
|
||||
$server->addGrantType($refrehTokenGrant);
|
||||
|
||||
// $refrehTokenGrant = new \League\OAuth2\Server\Grant\RefreshTokenGrant();
|
||||
// $server->addGrantType($refrehTokenGrant);
|
||||
|
Loading…
Reference in New Issue
Block a user