diff --git a/VERSION b/VERSION index 17e51c385ea382d4f2ef124b7032c1604845622d..0ea3a944b399d25f7e1b8fe684d754eb8da9fe7f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.1 +0.2.0 diff --git a/pirati.php b/pirati.php index 670cb74bc83608cd5da265dcf46362c54af47e00..e84ca7088cae323a6cee6e9835c49cfb89d60b0c 100644 --- a/pirati.php +++ b/pirati.php @@ -42,7 +42,7 @@ class pirati extends \phpbb\auth\provider\oauth\service\base $this->config = $config; $this->request = $request; - + global $phpbb_container; $language = $phpbb_container->get('language'); $language->add_lang(array('common', 'acp/common'), 'pirates/pirid'); @@ -88,7 +88,6 @@ class pirati extends \phpbb\auth\provider\oauth\service\base try { - // This was a callback request, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); } catch (\OAuth\Common\Http\Exception\TokenResponseException $e) @@ -106,7 +105,6 @@ class pirati extends \phpbb\auth\provider\oauth\service\base throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); } - // Prevent SQL error if (!isset($result['preferred_username'])) { throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_RETURN_ERROR'); @@ -128,7 +126,6 @@ class pirati extends \phpbb\auth\provider\oauth\service\base try { - // Send a request with it $result = (array) json_decode($this->service_provider->request('protocol/openid-connect/userinfo'), true); } catch (\OAuth\Common\Exception\Exception $e) @@ -136,13 +133,17 @@ class pirati extends \phpbb\auth\provider\oauth\service\base throw new exception('AUTH_PROVIDER_OAUTH_ERROR_REQUEST'); } - // Prevent SQL error if (!isset($result['preferred_username'])) { - throw new exception('AUTH_PROVIDER_OAUTH_RETURN_ERROR'); + throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_RETURN_ERROR'); } + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, "https://chobotnice.pirati.cz/import-person/" . $result['sub'] . "/"); + curl_exec($ch); + curl_close($ch); + return $result['sub']; - + } }