Merge branch 'V5-WIP' into unify_examples

This commit is contained in:
Julián Gutiérrez
2016-03-08 21:47:02 +01:00
106 changed files with 3172 additions and 4122 deletions

View File

@@ -14,7 +14,7 @@ use Psr\Http\Message\ServerRequestInterface;
use Slim\App;
use Zend\Diactoros\Stream;
include(__DIR__ . '/../vendor/autoload.php');
include __DIR__ . '/../vendor/autoload.php';
$app = new App([
'settings' => [
@@ -56,6 +56,22 @@ $app = new App([
},
]);
$app->any('/authorize', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */
$server = $app->getContainer()->get(Server::class);
try {
return $server->respondToRequest($request, $response);
} catch (OAuthServerException $exception) {
return $exception->generateHttpResponse($response);
} catch (\Exception $exception) {
$body = new Stream('php://temp', 'r+');
$body->write($exception->getMessage());
return $response->withStatus(500)->withBody($body);
}
});
$app->post('/access_token', function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {
/* @var \League\OAuth2\Server\Server $server */
$server = $app->getContainer()->get(Server::class);