refactor guthub api
[pharext/pharext.org] / app / Controller / Github / Callback.php
index d6d11920c6bd14ab3ecd465356536b1b49e94175..496baf331f9973def275201755e1ad658ca51c3c 100644 (file)
@@ -28,24 +28,20 @@ class Callback extends Github
                                "error" => $this->app->getRequest()->getQuery("error_description")
                        ]);
                } else {
-                       try {
-                               $this->github->fetchToken(
-                                       $this->app->getRequest()->getQuery("code"),
-                                       $this->app->getRequest()->getQuery("state"),
-                                       function($token) {
-                                               $this->github->setToken($token->access_token);
-                                               $this->github->fetchUser($this->createUserCallback($token));
-                               })->send();
-                               if (isset($this->session->returnto)) {
-                                       $returnto = $this->session->returnto;
-                                       unset($this->session->returnto);
-                                       $this->app->redirect($returnto);
-                               } else {
-                                       $this->app->redirect(
-                                               $this->app->getBaseUrl()->mod("./github"));
-                               }
-                       } catch (Exception $exception) {
-                               $this->app->getView()->addData(compact("exception"));
+                       $this->github->fetchToken(
+                               $this->app->getRequest()->getQuery("code"),
+                               $this->app->getRequest()->getQuery("state"),
+                               function($token) {
+                                       $this->github->setToken($token->access_token);
+                                       $this->github->fetchUser($this->createUserCallback($token));
+                       })->send();
+                       if (isset($this->session->returnto)) {
+                               $returnto = $this->session->returnto;
+                               unset($this->session->returnto);
+                               $this->app->redirect($returnto);
+                       } else {
+                               $this->app->redirect(
+                                       $this->app->getBaseUrl()->mod("./github"));
                        }
                }
                $this->app->display("github/callback");