Normalize domain input to lowercase in getExternalSession method and add authentication check

This commit is contained in:
netkas 2025-03-27 12:52:46 -04:00
parent fb31c3cc6a
commit eaccaacf96
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -734,6 +734,8 @@
*/ */
public static function getExternalSession(string $domain): SocialClient public static function getExternalSession(string $domain): SocialClient
{ {
$domain = strtolower($domain);
if(ExternalSessionManager::sessionExists($domain)) if(ExternalSessionManager::sessionExists($domain))
{ {
return new SocialClient(self::getServerAddress(), $domain, ExternalSessionManager::getSession($domain)); return new SocialClient(self::getServerAddress(), $domain, ExternalSessionManager::getSession($domain));
@ -749,6 +751,11 @@
throw new ResolutionException(sprintf('Failed to connect to remote server %s: %s', $domain, $e->getMessage()), $e->getCode(), $e); throw new ResolutionException(sprintf('Failed to connect to remote server %s: %s', $domain, $e->getMessage()), $e->getCode(), $e);
} }
if(!$client->getSessionState()->isAuthenticated())
{
throw new ResolutionException(sprintf('Failed to authenticate with remote server %s', $domain));
}
ExternalSessionManager::addSession($client->exportSession()); ExternalSessionManager::addSession($client->exportSession());
return $client; return $client;
} }