diff --git a/src/Provider/LogoutTrait.php b/src/Provider/LogoutTrait.php index b06fec6..0622716 100644 --- a/src/Provider/LogoutTrait.php +++ b/src/Provider/LogoutTrait.php @@ -14,7 +14,7 @@ trait LogoutTrait */ public function getBaseSessionLogoutUrl() { - return $this->wellKnown->end_session_endpoint; + return $this->getWellKnown()->end_session_endpoint; } /** diff --git a/src/Provider/PrestaShop.php b/src/Provider/PrestaShop.php index 7894238..b2156a0 100644 --- a/src/Provider/PrestaShop.php +++ b/src/Provider/PrestaShop.php @@ -57,6 +57,11 @@ class PrestaShop extends AbstractProvider */ protected $wellKnown; + /** + * @var bool + */ + protected $verify = true; + /** * @param array $options * @@ -67,8 +72,6 @@ class PrestaShop extends AbstractProvider public function __construct(array $options = [], array $collaborators = []) { parent::__construct($options, $collaborators); - - $this->wellKnown = new WellKnown($this->getOauth2Url(), $options['verify']); } /** @@ -79,12 +82,27 @@ public function getOauth2Url() return 'https://oauth.prestashop.com'; } + /** + * @return WellKnown + */ + public function getWellKnown() + { + if (! $this->wellKnown) { + try { + $this->wellKnown = new WellKnown($this->getOauth2Url(), $this->verify); + } catch (\Exception $e) { + $this->wellKnown = new WellKnown(); + } + } + return $this->wellKnown; + } + /** * @return string */ public function getBaseAuthorizationUrl() { - return $this->wellKnown->authorization_endpoint; + return $this->getWellKnown()->authorization_endpoint; } /** @@ -94,7 +112,7 @@ public function getBaseAuthorizationUrl() */ public function getBaseAccessTokenUrl(array $params) { - return $this->wellKnown->token_endpoint; + return $this->getWellKnown()->token_endpoint; } /** @@ -104,7 +122,7 @@ public function getBaseAccessTokenUrl(array $params) */ public function getResourceOwnerDetailsUrl(AccessToken $token) { - return $this->wellKnown->userinfo_endpoint; + return $this->getWellKnown()->userinfo_endpoint; } /**