From 6302bbfca7fcf1e8f0ebe755820b407f30cfb749 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andrej=20Rama=C5=A1euski?= <andrej@x2.cz>
Date: Wed, 21 Sep 2022 19:36:49 +0200
Subject: [PATCH] Callback on login and tocken

---
 VERSION    |  2 +-
 pirati.php | 21 ++++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/VERSION b/VERSION
index 0c62199..0d91a54 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.1
+0.3.0
diff --git a/pirati.php b/pirati.php
index 3b218a8..0102944 100644
--- a/pirati.php
+++ b/pirati.php
@@ -40,10 +40,10 @@ class pirati extends \phpbb\auth\provider\oauth\service\base
     public function __construct(\phpbb\config\config $config, \phpbb\request\request_interface $request)
     {
 
-	$this->config = $config;
+	    $this->config = $config;
         $this->request = $request;
 
-	global $phpbb_container;
+	    global $phpbb_container;
         $language = $phpbb_container->get('language');
         $language->add_lang(array('common', 'acp/common'), 'pirates/pirid');
 
@@ -76,6 +76,16 @@ class pirati extends \phpbb\auth\provider\oauth\service\base
         );
     }
 
+
+    function octopussy_callback()
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, "https://chobotnice.pirati.cz/import-person/" . $result['sub'] . "/");
+        curl_exec($ch);
+        curl_close($ch);
+    }
+
+
     /**
     * {@inheritdoc}
     */
@@ -110,11 +120,7 @@ class pirati extends \phpbb\auth\provider\oauth\service\base
                 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);
-
+        octopussy_callback();
         return $result['sub'];
 
     }
@@ -143,6 +149,7 @@ class pirati extends \phpbb\auth\provider\oauth\service\base
                 throw new \phpbb\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_RETURN_ERROR');
         }
 
+        octopussy_callback();
         return $result['sub'];
 
     }
-- 
GitLab