Alex Trofimov 2 rokov pred
rodič
commit
c48bc049d7

+ 5 - 1
modules/boonex/okta_connect/classes/BxOktaConConfig.php

@@ -14,7 +14,6 @@ class BxOktaConConfig extends BxBaseModConnectConfig
     public $sDomain;
     public $sClientID;
     public $sSecret;
-
     public $sScope = 'openid profile email'; // 'okta.users.read'; 
 
     public $sPageStart;
@@ -31,6 +30,7 @@ class BxOktaConConfig extends BxBaseModConnectConfig
         $this -> sDomain = getParam('bx_oktacon_domain');
         $this -> sClientID = getParam('bx_oktacon_client_id');
         $this -> sSecret = getParam('bx_oktacon_secret');
+        $this -> sScope = getParam('bx_oktacon_scope');
 
         $this -> sEmailTemplatePasswordGenerated = 'bx_oktacon_password_generated';
         $this -> sDefaultTitleLangKey = '_bx_oktacon';
@@ -42,6 +42,10 @@ class BxOktaConConfig extends BxBaseModConnectConfig
 
         $this -> sPageStart = BX_DOL_URL_ROOT . $this -> getBaseUri() . 'start';
         $this -> sPageHandle = BX_DOL_URL_ROOT . $this -> getBaseUri() . 'handle';
+
+        bx_import('Custom', $this->_aModule);
+        $oCustom = new BxOktaConCustom($aModule);
+        $oCustom->onConfig($aModule);
     }
 }
 

+ 39 - 0
modules/boonex/okta_connect/classes/BxOktaConCustom.php

@@ -0,0 +1,39 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    OktaConnect Okta Connect
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxOktaConCustom
+{
+    function __construct($aModule)
+    {
+    }
+
+    function onConfig ($oConfig)
+    {
+
+    }
+
+    function onRegister ($aRemoteProfileInfo)
+    {
+
+    }
+
+    function onLogin ($oProfile)
+    {
+
+    }
+
+    function onConvertRemoteFields($aProfileInfo, &$aProfileFields)
+    {
+
+    }
+}
+
+/** @} */

+ 10 - 1
modules/boonex/okta_connect/classes/BxOktaConModule.php

@@ -111,16 +111,21 @@ echoDbgLog($s);
 */
         if ($aRemoteProfileInfo) {
 
+            bx_import('Custom', $this->_aModule);
+            $oCustom = new BxOktaConCustom($this->_aModule);
+
             // check if user logged in before
             $iLocalProfileId = $this->_oDb->getProfileId($aRemoteProfileInfo['id']);
             
             if ($iLocalProfileId && $oProfile = BxDolProfile::getInstance($iLocalProfileId)) {
                 // user already exists
-                $this->setLogged($oProfile ->id(), '', true, true); // remember user
+                $this->setLogged($oProfile->id(), '', true, getParam('bx_oktacon_remember_session')); // remember user
+                $oCustom->onLogin($oProfile);
             }             
             else {  
                 // register new user
                 $this->_createProfile($aRemoteProfileInfo);
+                $oCustom->onRegister($aRemoteProfileInfo);
             }
         } 
         else {
@@ -144,6 +149,10 @@ echoDbgLog($s);
         $aProfileFields['picture'] = '';
         $aProfileFields['allow_view_to'] = getParam('bx_oktacon_privacy');
 
+        bx_import('Custom', $this->_aModule);
+        $oCustom = new BxOktaConCustom($this->_aModule);
+        $oCustom->onConvertRemoteFields($aProfileInfo, $aProfileFields);
+
         return $aProfileFields;
     }
 

+ 2 - 0
modules/boonex/okta_connect/install/langs/en.xml

@@ -13,6 +13,8 @@
     <string name="_bx_oktacon_option_domain"><![CDATA[Okta Domain]]></string>
     <string name="_bx_oktacon_option_client_id"><![CDATA[Application (Client) ID]]></string>
     <string name="_bx_oktacon_option_secret"><![CDATA[Client Secret Value]]></string>
+    <string name="_bx_oktacon_option_scope"><![CDATA[Scope]]></string>
+    <string name="_sys_connect_option_remember_session"><![CDATA[Remember user session]]></string>
 
 	<string name="_bx_oktacon_et_password_generated"><![CDATA[Okta connect temporary password]]></string>
 	<string name="_bx_oktacon_et_password_generated_subject"><![CDATA[Temporary password]]></string>

+ 3 - 1
modules/boonex/okta_connect/install/sql/enable.sql

@@ -35,9 +35,11 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_oktacon_domain', '', @iCategId, '_bx_oktacon_option_domain', 'digit', '', '', 20, ''),
 ('bx_oktacon_client_id', '', @iCategId, '_bx_oktacon_option_client_id', 'digit', '', '', 22, ''),
 ('bx_oktacon_secret', '', @iCategId, '_bx_oktacon_option_secret', 'digit', '', '', 24, ''),
+('bx_oktacon_scope', 'openid profile email', @iCategId, '_bx_oktacon_option_scope', 'digit', '', '', 26, ''),
 ('bx_oktacon_redirect_page', 'index', @iCategId, '_sys_connect_option_redirect', 'select', '', '', 40, 'join,settings,dashboard,index'),
 ('bx_oktacon_module', 'bx_persons', @iCategId, '_sys_connect_option_module', 'select', '', '', 50, 'a:2:{s:6:"module";s:10:"bx_oktacon";s:6:"method";s:20:"get_profiles_modules";}'),
 ('bx_oktacon_privacy', '3', @iCategId, '_sys_connect_option_privacy', 'select', '', '', 54, 'a:2:{s:6:"module";s:10:"bx_oktacon";s:6:"method";s:18:"get_privacy_groups";}'),
 ('bx_oktacon_confirm_email', 'on', @iCategId, '_sys_connect_option_confirm_email', 'checkbox', '', '', 70, ''),
-('bx_oktacon_approve', '', @iCategId, '_sys_connect_option_approve', 'checkbox', '', '', 80, '');
+('bx_oktacon_approve', '', @iCategId, '_sys_connect_option_approve', 'checkbox', '', '', 80, ''),
+('bx_oktacon_remember_session', 'on', @iCategId, '_sys_connect_option_remember_session', 'checkbox', '', '', 100, '');