Skip to content

Commit

Permalink
Added flag parameter for testing credentials - they could not be test…
Browse files Browse the repository at this point in the history
…ed before saving configuration
  • Loading branch information
ivanviduka committed Jul 17, 2023
1 parent de6c76b commit fbfae9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions Model/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
}

Expand Down

0 comments on commit fbfae9b

Please sign in to comment.