/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Authenticator
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Authenticator/SocialAuthenticator.php (4214B)
getAttribute(self::SOCIAL_SERVICE_ATTRIBUTE);
if ($service === null) {
return new Result(null, Result::FAILURE_CREDENTIALS_MISSING);
}
$rawData = $this->getRawData($request, $service);
if (empty($rawData)) {
return new Result(null, Result::FAILURE_IDENTITY_NOT_FOUND);
}
return $this->identify($rawData);
}
/**
* Identify user with credential data
*
* @param array $rawData social user raw data
* @return \Authentication\Authenticator\Result
*/
protected function identify($rawData)
{
$user = $this->getIdentifier()->identify([SocialIdentifier::CREDENTIAL_KEY => $rawData]);
if (!empty($user)) {
return new Result($user, Result::SUCCESS);
}
return new Result(null, Result::FAILURE_IDENTITY_NOT_FOUND);
}
/**
* Get user raw data from social provider
*
* @param \Psr\Http\Message\ServerRequestInterface $request request object
* @param \CakeDC\Auth\Social\Service\ServiceInterface $service social service
* @throws \Exception
* @return array|null
*/
private function getRawData(ServerRequestInterface $request, ServiceInterface $service)
{
$rawData = null;
try {
$rawData = $service->getUser($request);
$mapper = new MapUser();
return $mapper($service, $rawData);
} catch (\Exception $exception) {
$list = [BadRequestException::class, \UnexpectedValueException::class];
$this->throwIfNotInlist($exception, $list);
$message = sprintf(
"Error getting an access token / retrieving the authorized user's profile data. Error message: %s %s",
$exception->getMessage(),
$exception
);
$this->log($message);
return null;
}
}
/**
* Throw the exception if not in the list
*
* @param \Exception $exception exception thrown
* @param array $list list of allowed exception classes
* @throws \Exception
* @return void
*/
private function throwIfNotInlist(\Exception $exception, array $list)
{
$className = get_class($exception);
if (!in_array($className, $list)) {
throw $exception;
}
}
}