- 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);
- }
- $token = $account->updateToken("github", $oauth->access_token, $oauth);
- $owner = $account->updateOwner("github", $user->login, $user);
-
- $tx->commit();
-
- $this->login($account, $token, $owner);
- };
+ $this->github->drain();
+ }
+
+ private function persistUser($oauth, $user) {
+ $tx = $this->accounts->getConnection()->startTransaction();
+
+ 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);
+ }
+ $token = $account->updateToken("github", $oauth->access_token, $oauth);
+ $owner = $account->updateOwner("github", $user->login, $user);
+
+ $tx->commit();
+
+ return [$account, $token, $owner];