Skip to content
Snippets Groups Projects
Verified Commit dce91d04 authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Chobotnice callback

parent ae95588a
No related branches found
No related tags found
No related merge requests found
0.1.1
0.2.0
......@@ -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'];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment