X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=app%2FController%2FGithub%2FCallback.php;h=e6429fcf7de18f57ef2b313fa2247224b75b7cc4;hb=9815b77a14832685f90d34f9a348af1cadd63576;hp=646d782f20d52c59676efdbd23a72a39ddd3c5ba;hpb=498633479633aaaaea5d848b4f466821f15b205f;p=pharext%2Fpharext.org diff --git a/app/Controller/Github/Callback.php b/app/Controller/Github/Callback.php index 646d782..e6429fc 100644 --- a/app/Controller/Github/Callback.php +++ b/app/Controller/Github/Callback.php @@ -7,6 +7,7 @@ use app\Github\API; use app\Model\Accounts; use app\Session; use app\Web; +use http\Cookie; class Callback extends Github { @@ -45,20 +46,21 @@ class Callback extends Github $this->app->display("github/callback"); } - function createUserCallback($token) { - return function($user) use($token) { + function createUserCallback($oauth) { + return function($user) use($oauth) { $tx = $this->accounts->getConnection()->startTransaction(); - - if (!($account = $this->accounts->byOAuth("github", $token->access_token, $user->login))) { - $account = $this->accounts->createOAuthAccount("github", $token->access_token, $user->login); + + if (($cookie = $this->app->getRequest()->getCookie("account"))) { + $account = $this->accounts->find(["account=" => $cookie])->current(); + } elseif (!($account = $this->accounts->byOAuth("github", $oauth->access_token, $user->login))) { + $account = $this->accounts->createOAuthAccount("github", $oauth->access_token, $user->login); } - $account->updateToken("github", $token->access_token, $token); + $token = $account->updateToken("github", $oauth->access_token, $oauth); $owner = $account->updateOwner("github", $user->login, $user); $tx->commit(); - $this->session->account = $account->account->get(); - $this->session->github = (object) $owner->export(); + $this->login($account, $token, $owner); }; } }