Demonstrate how to redirect

This commit is contained in:
Alex Bilbie 2014-11-08 17:05:18 +00:00
parent 8131b71e26
commit 8e90033594

View File

@ -38,6 +38,12 @@ $router->get('/oauth', function (Request $request) use ($server) {
} catch (\Exception $e) { } catch (\Exception $e) {
if ($e->shouldRedirect()) {
return new Response('', 302, [
'Location' => $e->getRedirectUri()
]);
}
return new Response( return new Response(
json_encode([ json_encode([
'error' => $e->errorType, 'error' => $e->errorType,
@ -51,12 +57,10 @@ $router->get('/oauth', function (Request $request) use ($server) {
// Everything is okay, save $authParams to the a session and redirect the user to sign-in // Everything is okay, save $authParams to the a session and redirect the user to sign-in
$response = new Response('', 302, [ return = new Response('', 302, [
'Location' => '/signin' 'Location' => '/signin'
]); ]);
return $response;
}); });
~~~ ~~~