From a91fa2c9b8507c29729bd6a56e8a98c2c10129cb Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Wed, 19 Feb 2020 16:54:21 +0100 Subject: [PATCH] Don't duplicate Hybridauth config in e107::getHybridAuth() --- e107_handlers/e107_class.php | 22 ++++++++-------------- e107_tests/tests/unit/e107Test.php | 6 ++++-- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index c5b671d2c..73c5d89ce 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1707,7 +1707,8 @@ class e107 * Create a new Hybridauth object based on the provided configuration * * @return Hybridauth\Hybridauth - * @throws \Hybridauth\Exception\InvalidArgumentException + * @throws \Hybridauth\Exception\InvalidArgumentException if Hybridauth rejects the provided config + * @throws ReflectionException if this method is unintentionally broken * @deprecated v2.3.0 Use the e_user_provider interfaces instead (e107::getUser()->getProvider()). * Hybridauth features are only available if the user is associated with a social login. * @see e107::getUser() for getting a user object that may or may not have a social login. @@ -1715,19 +1716,12 @@ class e107 */ public static function getHybridAuth($config = null) { - if(null === $config) - { - require_once(e_PLUGIN . "social/SocialLoginConfigManager.php"); - $manager = new SocialLoginConfigManager(e107::getConfig()); - - $config = array( - 'callback' => self::getUrl()->create('system/xup/login', array(), array('full' => true)), - 'providers' => $manager->getValidConfiguredProviderConfigs(), - 'debug_mode' => false, - 'debug_file' => '' - ); - } - return new Hybridauth\Hybridauth($config); + include_once("user_handler.php"); + $e_user_provider = new e_user_provider(null, $config); + $reflection = new ReflectionClass('e_user_provider'); + $reflection_property = $reflection->getProperty('hybridauth'); + $reflection_property->setAccessible(true); + return $reflection_property->getValue($e_user_provider); } /** diff --git a/e107_tests/tests/unit/e107Test.php b/e107_tests/tests/unit/e107Test.php index c8ec8e586..6f67b740d 100644 --- a/e107_tests/tests/unit/e107Test.php +++ b/e107_tests/tests/unit/e107Test.php @@ -439,13 +439,15 @@ class e107Test extends \Codeception\Test\Unit $res = null; $this->assertTrue($res); } + */ public function testGetHybridAuth() { - $res = null; - $this->assertTrue($res); + $object = e107::getHybridAuth(); + $this->assertInstanceOf(Hybridauth\Hybridauth::class, $object); } + /* public function testGetUserClass() { $res = null;