1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 14:46:56 +02:00

Suppress uncaught Hybridauth exceptions in e_user_provider

And add a check for those exceptions in
`social_ui::generateSocialLoginSection()`

Fixes: #4192
This commit is contained in:
Nick Liu
2021-12-28 11:51:20 +01:00
parent b40288d665
commit 3f59b3bc14
3 changed files with 64 additions and 8 deletions

View File

@@ -1171,16 +1171,30 @@ class e_user_provider
}
$this->respawnHybridauth();
$this->setProvider($provider);
$providerId = $this->getProvider();
if ($providerId && $this->hybridauth->isConnectedWith($providerId))
try
{
$this->adapter = $this->hybridauth->getAdapter($providerId);
$this->respawnHybridauth();
$this->setProvider($provider);
$providerId = $this->getProvider();
if ($providerId && $this->hybridauth->isConnectedWith($providerId))
{
$this->adapter = $this->hybridauth->getAdapter($providerId);
}
}
catch (\Hybridauth\Exception\InvalidArgumentException $e)
{
if (!$suppress_exceptions) throw $e;
}
catch (\Hybridauth\Exception\UnexpectedValueException $e)
{
if (!$suppress_exceptions) throw $e;
}
}
/**
* @throws \Hybridauth\Exception\InvalidArgumentException
*/
private function respawnHybridauth()
{
$this->hybridauth = new Hybridauth\Hybridauth($this->_config);
@@ -1237,9 +1251,10 @@ class e_user_provider
/**
* Get the social login providers for which we have adapters
*
* This function is slow! Please cache the output instead of calling it multiple times.
* Despite this being a static method, it memoizes (caches) the slow reflection code in the {@link e107} registry
* after the first run, so subsequent calls to this method are fast.
*
* @return array String list of supported providers. Empty if Hybridauth is broken.
* @return string[] String list of supported providers. Empty if Hybridauth is broken.
*/
public static function getSupportedProviders()
{