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();
$this->app->redirect($returnto);
} else {
$this->app->redirect(
- $this->app->getBaseUrl()->mod("./github"));
+ $this->app->getBaseUrl()->mod(":./github"));
}
}
$this->app->display("github/callback");
$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) {