Skip to content

Commit 5107197

Browse files
authored
Merge pull request #649 from favicode/fix/credentials-test-from-admin
Added flag parameter for testing credentials
2 parents 970fd59 + 061e9ba commit 5107197

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Controller/Adminhtml/FastlyCdn/Configuration/TestConnection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public function execute()
114114
$this->api->sendWebHook('*initiated test connection action*');
115115
}
116116

117-
$service = $this->api->checkServiceDetails(true, $serviceId, $apiKey);
117+
// Set isInitialCheck flag to true - we can test credentials even if they are not saved in database
118+
$service = $this->api->checkServiceDetails(true, $serviceId, $apiKey, true);
118119
$sendValidationReq = $this->statistic->sendValidationRequest(true, $serviceId);
119120
$this->saveValidationState(true, $sendValidationReq);
120121
} catch (\Exception $e) {

Model/Api.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,12 +383,13 @@ public function getCustomerInfo()
383383
* @param bool $test
384384
* @param null $serviceId
385385
* @param null $apiKey
386+
* @param bool $isInitialCheck - flag for testing credentials before Service ID and token are saved to config
386387
* @return bool|mixed
387388
* @throws LocalizedException
388389
*/
389-
public function checkServiceDetails($test = false, $serviceId = null, $apiKey = null)
390+
public function checkServiceDetails($test = false, $serviceId = null, $apiKey = null, $isInitialCheck = false)
390391
{
391-
if (!$this->config->isServiceConfigured()) {
392+
if (!$isInitialCheck && !$this->config->isServiceConfigured()) {
392393
throw new LocalizedException(__('Fastly service is not configured.'));
393394
}
394395

0 commit comments

Comments
 (0)