getProfile(); if (! empty($profile)) { $this->userInfo = new GithubUserProvider($profile); return true; } return false; } /** * Set Code * * @access public * @param string $code * @return GithubAuth */ public function setCode($code) { $this->code = $code; return $this; } /** * Get user object * * @access public * @return GithubUserProvider */ public function getUser() { return $this->userInfo; } /** * Get configured OAuth2 service * * @access public * @return \Kanboard\Core\Http\OAuth2 */ public function getService() { if (empty($this->service)) { $this->service = $this->oauth->createService( GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, $this->helper->url->to('oauth', 'github', array(), '', true), GITHUB_OAUTH_AUTHORIZE_URL, GITHUB_OAUTH_TOKEN_URL, array() ); } return $this->service; } /** * Get Github profile * * @access private * @return array */ private function getProfile() { $this->getService()->getAccessToken($this->code); return $this->httpClient->getJson( GITHUB_API_URL.'user', array($this->getService()->getAuthorizationHeader()) ); } /** * Unlink user * * @access public * @param integer $userId * @return bool */ public function unlink($userId) { return $this->user->update(array('id' => $userId, 'github_id' => '')); } }