X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=app%2FController%2FGithub.php;h=7b7bdf64d976547cee05bd7331439cfe6c102a5f;hb=9815b77a14832685f90d34f9a348af1cadd63576;hp=164f3205134070d8464ca6927382151f9f050594;hpb=498633479633aaaaea5d848b4f466821f15b205f;p=pharext%2Fpharext.org diff --git a/app/Controller/Github.php b/app/Controller/Github.php index 164f320..7b7bdf6 100644 --- a/app/Controller/Github.php +++ b/app/Controller/Github.php @@ -4,11 +4,14 @@ namespace app\Controller; use app\Controller; use app\Github\API; +use app\Model\Account; +use app\Model\Owner; +use app\Model\Token; use app\Session; use app\Web; - -use http\QueryString; +use http\Cookie; use http\Header; +use http\QueryString; abstract class Github implements Controller { @@ -18,12 +21,12 @@ abstract class Github implements Controller protected $app; /** - * @var \app\Github\API + * @var API */ protected $github; /** - * @var \app\Session + * @var Session */ protected $session; @@ -47,6 +50,19 @@ abstract class Github implements Controller } } + protected function login(Account $account, Token $token, Owner $owner) { + $auth = new Cookie; + $auth->setCookie("account", $account->account->get()); + $auth->setFlags(Cookie::SECURE | Cookie::HTTPONLY); + $auth->setPath($this->app->getBaseUrl()->path); + $auth->setMaxAge(60*60*24); + $this->app->getResponse()->setCookie($auth); + + $this->github->setToken($token->token->get()); + $this->session->account = $account->account->get(); + $this->session->github = (object) $owner->export(); + } + protected function checkToken() { if ($this->github->hasToken()) { return true;