getProfile(); if (! empty($profile)) { $this->userInfo = new GitlabUserProvider($profile); return true; } return false; } /** * Set Code * * @access public * @param string $code * @return GitlabAuth */ public function setCode($code) { $this->code = $code; return $this; } /** * Get user object * * @access public * @return GitlabUserProvider */ 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( GITLAB_CLIENT_ID, GITLAB_CLIENT_SECRET, $this->helper->url->to('oauth', 'gitlab', array(), '', true), GITLAB_OAUTH_AUTHORIZE_URL, GITLAB_OAUTH_TOKEN_URL, array() ); } return $this->service; } /** * Get Gitlab profile * * @access private * @return array */ private function getProfile() { $this->getService()->getAccessToken($this->code); return $this->httpClient->getJson( GITLAB_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, 'gitlab_id' => '')); } }