mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 16:13:54 +00:00
Catch OpenSSL error.
This commit is contained in:
@@ -26,6 +26,7 @@ use bunq\Context\ApiContext;
|
|||||||
use bunq\Exception\BadRequestException;
|
use bunq\Exception\BadRequestException;
|
||||||
use bunq\Exception\BunqException;
|
use bunq\Exception\BunqException;
|
||||||
use bunq\Util\BunqEnumApiEnvironmentType;
|
use bunq\Util\BunqEnumApiEnvironmentType;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Services\IP\IPRetrievalInterface;
|
use FireflyIII\Services\IP\IPRetrievalInterface;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
@@ -122,9 +123,16 @@ class BunqPrerequisites implements PrerequisitesInterface
|
|||||||
$deviceDescription,
|
$deviceDescription,
|
||||||
$permittedIps
|
$permittedIps
|
||||||
);
|
);
|
||||||
} catch (BadRequestException $e) {
|
} catch (BadRequestException|BunqException|Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
Log::error($e->getTraceAsString());
|
||||||
|
$message = $e->getMessage();
|
||||||
|
if (stripos($message, 'Generating a new private key failed')) {
|
||||||
|
$message = 'Could not generate key-material. Please make sure OpenSSL is installed and configured: http://bit.ly/FF3-openSSL';
|
||||||
|
|
||||||
|
}
|
||||||
$messages = new MessageBag();
|
$messages = new MessageBag();
|
||||||
$messages->add('bunq_error', $e->getMessage());
|
$messages->add('bunq_error', $message);
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
@@ -25,9 +25,12 @@ namespace FireflyIII\Support\Import\Routine\Bunq;
|
|||||||
|
|
||||||
use bunq\Context\ApiContext;
|
use bunq\Context\ApiContext;
|
||||||
use bunq\Context\BunqContext;
|
use bunq\Context\BunqContext;
|
||||||
|
use bunq\Exception\BadRequestException;
|
||||||
|
use bunq\Exception\BunqException;
|
||||||
use bunq\Model\Generated\Endpoint\Payment;
|
use bunq\Model\Generated\Endpoint\Payment;
|
||||||
use bunq\Model\Generated\Object\LabelMonetaryAccount;
|
use bunq\Model\Generated\Object\LabelMonetaryAccount;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Factory\AccountFactory;
|
use FireflyIII\Factory\AccountFactory;
|
||||||
use FireflyIII\Models\Account as LocalAccount;
|
use FireflyIII\Models\Account as LocalAccount;
|
||||||
@@ -242,7 +245,18 @@ class StageImportDataHandler
|
|||||||
$preference = app('preferences')->getForUser($this->importJob->user, 'bunq_api_context', null);
|
$preference = app('preferences')->getForUser($this->importJob->user, 'bunq_api_context', null);
|
||||||
if (null !== $preference && '' !== (string)$preference->data) {
|
if (null !== $preference && '' !== (string)$preference->data) {
|
||||||
// restore API context
|
// restore API context
|
||||||
$apiContext = ApiContext::fromJson($preference->data);
|
try {
|
||||||
|
$apiContext = ApiContext::fromJson($preference->data);
|
||||||
|
} catch (BadRequestException|BunqException|Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
Log::error($e->getTraceAsString());
|
||||||
|
$message = $e->getMessage();
|
||||||
|
if (stripos($message, 'Generating a new private key failed')) {
|
||||||
|
$message = 'Could not generate key-material. Please make sure OpenSSL is installed and configured: http://bit.ly/FF3-openSSL';
|
||||||
|
|
||||||
|
}
|
||||||
|
throw new FireflyException($message);
|
||||||
|
}
|
||||||
BunqContext::loadApiContext($apiContext);
|
BunqContext::loadApiContext($apiContext);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@@ -25,14 +25,18 @@ namespace FireflyIII\Support\Import\Routine\Bunq;
|
|||||||
|
|
||||||
use bunq\Context\ApiContext;
|
use bunq\Context\ApiContext;
|
||||||
use bunq\Context\BunqContext;
|
use bunq\Context\BunqContext;
|
||||||
|
use bunq\Exception\BadRequestException;
|
||||||
|
use bunq\Exception\BunqException;
|
||||||
use bunq\Model\Generated\Endpoint\MonetaryAccount;
|
use bunq\Model\Generated\Endpoint\MonetaryAccount;
|
||||||
use bunq\Model\Generated\Endpoint\MonetaryAccountBank;
|
use bunq\Model\Generated\Endpoint\MonetaryAccountBank;
|
||||||
use bunq\Model\Generated\Object\Pointer;
|
use bunq\Model\Generated\Object\Pointer;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Models\Preference;
|
use FireflyIII\Models\Preference;
|
||||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||||
use Log;
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class StageNewHandler
|
* Class StageNewHandler
|
||||||
*/
|
*/
|
||||||
@@ -52,16 +56,28 @@ class StageNewHandler
|
|||||||
$preference = app('preferences')->getForUser($this->importJob->user, 'bunq_api_context', null);
|
$preference = app('preferences')->getForUser($this->importJob->user, 'bunq_api_context', null);
|
||||||
if (null !== $preference && '' !== (string)$preference->data) {
|
if (null !== $preference && '' !== (string)$preference->data) {
|
||||||
// restore API context
|
// restore API context
|
||||||
$apiContext = ApiContext::fromJson($preference->data);
|
try {
|
||||||
BunqContext::loadApiContext($apiContext);
|
$apiContext = ApiContext::fromJson($preference->data);
|
||||||
|
BunqContext::loadApiContext($apiContext);
|
||||||
|
} catch (BadRequestException|BunqException|Exception $e) {
|
||||||
|
Log::error($e->getMessage());
|
||||||
|
Log::error($e->getTraceAsString());
|
||||||
|
$message = $e->getMessage();
|
||||||
|
if (stripos($message, 'Generating a new private key failed')) {
|
||||||
|
$message = 'Could not generate key-material. Please make sure OpenSSL is installed and configured: http://bit.ly/FF3-openSSL';
|
||||||
|
|
||||||
|
}
|
||||||
|
throw new FireflyException($message);
|
||||||
|
}
|
||||||
|
|
||||||
// list bunq accounts:
|
// list bunq accounts:
|
||||||
$accounts = $this->listAccounts();
|
$accounts = $this->listAccounts();
|
||||||
|
|
||||||
// store in job:
|
// store in job:
|
||||||
$config = $this->repository->getConfiguration($this->importJob);
|
$config = $this->repository->getConfiguration($this->importJob);
|
||||||
$config['accounts'] = $accounts;
|
$config['accounts'] = $accounts;
|
||||||
$this->repository->setConfiguration($this->importJob, $config);
|
$this->repository->setConfiguration($this->importJob, $config);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new FireflyException('The bunq API context is unexpectedly empty.');
|
throw new FireflyException('The bunq API context is unexpectedly empty.');
|
||||||
|
Reference in New Issue
Block a user