diff --git a/Controller/Adminhtml/FastlyCdn/Configuration/TestConnection.php b/Controller/Adminhtml/FastlyCdn/Configuration/TestConnection.php index 2bfa5b89..1f0567b0 100644 --- a/Controller/Adminhtml/FastlyCdn/Configuration/TestConnection.php +++ b/Controller/Adminhtml/FastlyCdn/Configuration/TestConnection.php @@ -114,7 +114,8 @@ public function execute() $this->api->sendWebHook('*initiated test connection action*'); } - $service = $this->api->checkServiceDetails(true, $serviceId, $apiKey); + // Set isInitialCheck flag to true - we can test credentials even if they are not saved in database + $service = $this->api->checkServiceDetails(true, $serviceId, $apiKey, true); $sendValidationReq = $this->statistic->sendValidationRequest(true, $serviceId); $this->saveValidationState(true, $sendValidationReq); } catch (\Exception $e) { diff --git a/Model/Api.php b/Model/Api.php index ada10493..eea3f3d7 100644 --- a/Model/Api.php +++ b/Model/Api.php @@ -383,12 +383,13 @@ public function getCustomerInfo() * @param bool $test * @param null $serviceId * @param null $apiKey + * @param bool $isInitialCheck - flag for testing credentials before Service ID and token are saved to config * @return bool|mixed * @throws LocalizedException */ - public function checkServiceDetails($test = false, $serviceId = null, $apiKey = null) + public function checkServiceDetails($test = false, $serviceId = null, $apiKey = null, $isInitialCheck = false) { - if (!$this->config->isServiceConfigured()) { + if (!$this->config->isServiceConfigured() && !$isInitialCheck) { throw new LocalizedException(__('Fastly service is not configured.')); }