Merge pull request #271 from inverse/example-fix

Example fix
This commit is contained in:
Alex Bilbie 2014-12-10 15:12:40 +00:00
commit 27f51d33e1

View File

@ -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'];
}