Skip to content

Commit

Permalink
Merge pull request #23 from matomo-org/handle-invalid-config-better
Browse files Browse the repository at this point in the history
If invalid or missing config is found delete existing client configuration.
  • Loading branch information
diosmosis authored Nov 20, 2019
2 parents c038da0 + 46f72b0 commit 6dc1b97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@
use Piwik\Date;
use Piwik\Nonce;
use Piwik\Notification;
use Piwik\Option;
use Piwik\Piwik;
use Piwik\Plugins\GoogleAnalyticsImporter\Commands\ImportReports;
use Piwik\Plugins\GoogleAnalyticsImporter\Google\Authorization;
use Piwik\Plugins\SearchEngineKeywordsPerformance\Exceptions\MissingClientConfigException;
use Piwik\Plugins\SearchEngineKeywordsPerformance\Exceptions\MissingOAuthConfigException;
use Piwik\Plugins\SearchEngineKeywordsPerformance\Provider\Google as ProviderGoogle;
use Piwik\Plugins\SearchEngineKeywordsPerformance\Provider\Bing as ProviderBing;
use Piwik\Plugins\SearchEngineKeywordsPerformance\Provider\ProviderAbstract;
use Piwik\Plugins\WebsiteMeasurable\Type as WebsiteMeasurableType;
use Piwik\Site;
use Piwik\Url;
use Psr\Log\LoggerInterface;

Expand All @@ -51,7 +43,13 @@ public function index($errorMessage = false)

$hasClientConfiguration = $authorization->hasClientConfiguration();
if ($hasClientConfiguration) {
$googleClient = $authorization->getConfiguredClient();
try {
$googleClient = $authorization->getConfiguredClient();
} catch (\Exception $ex) {
$authorization->deleteClientConfiguration();

throw $ex;
}

$authUrl = $googleClient->createAuthUrl();

Expand Down
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AdminMenuTitle": "Google Analytics Import",
"ConfigureTheImporter": "Configure the Importer",
"InvalidClientJson": "Invalid JSON in credentials file, try re-downloading the file from the Google API Console.",
"MissingClientConfiguration": "Missing client configuration.",
"MissingClientConfiguration": "Missing or invalid client configuration, please reupload.",
"SettingUp": "Setting Up",
"ImporterHelp1": "The Google Analytics Importer requires you to set up OAuth Client configuration in the Google API Console before you can do anything else.",
"ImporterHelp2": "To see a step-by-step guide for doing this and setting up this plugin %1$sclick here.%2$s",
Expand Down

0 comments on commit 6dc1b97

Please sign in to comment.