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