From 8e9003359452e8fd3126d20dabf7a73a2f0832d1 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 8 Nov 2014 17:05:18 +0000 Subject: [PATCH] Demonstrate how to redirect --- auth-server-auth-code.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/auth-server-auth-code.md b/auth-server-auth-code.md index 0667c86b..438ae0f9 100755 --- a/auth-server-auth-code.md +++ b/auth-server-auth-code.md @@ -38,6 +38,12 @@ $router->get('/oauth', function (Request $request) use ($server) { } catch (\Exception $e) { + if ($e->shouldRedirect()) { + return new Response('', 302, [ + 'Location' => $e->getRedirectUri() + ]); + } + return new Response( json_encode([ '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 - $response = new Response('', 302, [ + return = new Response('', 302, [ 'Location' => '/signin' ]); - return $response; - }); ~~~