mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-30 02:33:14 +05:30
commit
27f51d33e1
@ -34,12 +34,14 @@ $router = new \Orno\Route\RouteCollection();
|
||||
// GET /tokeninfo
|
||||
$router->get('/tokeninfo', function (Request $request) use ($server) {
|
||||
|
||||
$accessToken = $server->getAccessToken();
|
||||
$session = $server->getSessionStorage()->getByAccessToken($accessToken);
|
||||
$token = [
|
||||
'owner_id' => $server->getOwnerId(),
|
||||
'owner_type' => $server->getOwnerType(),
|
||||
'access_token' => $server->getAccessToken(),
|
||||
'client_id' => $server->getClientId(),
|
||||
'scopes' => $server->getScopes(),
|
||||
'owner_id' => $session->getOwnerId(),
|
||||
'owner_type' => $session->getOwnerType(),
|
||||
'access_token' => $accessToken,
|
||||
'client_id' => $session->getClient()->getId(),
|
||||
'scopes' => $accessToken->getScopes(),
|
||||
];
|
||||
|
||||
return new Response(json_encode($token));
|
||||
@ -59,11 +61,11 @@ $router->get('/users', function (Request $request) use ($server) {
|
||||
'name' => $result['name'],
|
||||
];
|
||||
|
||||
if ($server->hasScope('email')) {
|
||||
if ($server->getAccessToken()->hasScope('email')) {
|
||||
$user['email'] = $result['email'];
|
||||
}
|
||||
|
||||
if ($server->hasScope('photo')) {
|
||||
if ($server->getAccessToken()->hasScope('photo')) {
|
||||
$user['photo'] = $result['photo'];
|
||||
}
|
||||
|
||||
@ -87,11 +89,11 @@ $router->get('/users/{username}', function (Request $request, $args) use ($serve
|
||||
'name' => $result[0]['name'],
|
||||
];
|
||||
|
||||
if ($server->hasScope('email')) {
|
||||
if ($server->getAccessToken()->hasScope('email')) {
|
||||
$user['email'] = $result[0]['email'];
|
||||
}
|
||||
|
||||
if ($server->hasScope('photo')) {
|
||||
if ($server->getAccessToken()->hasScope('photo')) {
|
||||
$user['photo'] = $result[0]['photo'];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user