X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub%2FCallback.php;h=2347d0e67069ca946dbea6c924af10e59b312f06;hb=f71f7713ee19492c1355efb9bef8ecb5e01f6a4c;hp=baa6c4d47389f0d4aba92eede281c180f2e742f0;hpb=2198c781a021d85ee845f2f4b2f5c322f73e6bd5;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/Callback.php b/app/Controller/Github/Callback.php index baa6c4d..2347d0e 100644 --- a/app/Controller/Github/Callback.php +++ b/app/Controller/Github/Callback.php @@ -23,9 +23,7 @@ class Callback extends Github function __invoke(array $args = null) { if ($this->app->getRequest()->getQuery("error")) { - $this->app->getView()->addData([ - "error" => $this->app->getRequest()->getQuery("error_description") - ]); + $this->app->getView()->addData($this->app->getRequest()->getQuery()->toArray()); } else { $this->validateUser(); @@ -35,7 +33,7 @@ class Callback extends Github $this->app->redirect($returnto); } else { $this->app->redirect( - $this->app->getBaseUrl()->mod("./github")); + $this->app->getBaseUrl()->mod(":./github")); } } $this->app->display("github/callback"); @@ -45,18 +43,16 @@ class Callback extends Github $this->github->fetchToken( $this->app->getRequest()->getQuery("code"), $this->app->getRequest()->getQuery("state") - )->then(function($result) { + )->then(function($result) use (&$oauth) { list($oauth) = $result; $this->github->setToken($oauth->access_token); - return $this->github->readAuthUser()->then(function($result) use($oauth) { - list($user) = $result; - return $this->persistUser($oauth, $user); - }); - })->done(function($result) { - $this->login(...$result); + return $this->github->readAuthUser(); + })->done(function($result) use(&$oauth) { + list($user) = $result; + $this->login(...$this->persistUser($oauth, $user)); }); - $this->github->getClient()->send(); + $this->github->drain(); } private function persistUser($oauth, $user) {