mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Last attempt I hope for #2125
This commit is contained in:
@@ -224,23 +224,6 @@ class Amount
|
|||||||
return $this->getDefaultCurrencyByUser($user);
|
return $this->getDefaultCurrencyByUser($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function tryDecrypt(string $value): string
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$value = Crypt::decrypt($value);
|
|
||||||
} catch (DecryptException $e) {
|
|
||||||
Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param User $user
|
* @param User $user
|
||||||
*
|
*
|
||||||
@@ -260,7 +243,13 @@ class Amount
|
|||||||
|
|
||||||
// at this point the currency preference could be encrypted, if coming from an old version.
|
// at this point the currency preference could be encrypted, if coming from an old version.
|
||||||
$currencyCode = $this->tryDecrypt((string)$currencyPreference->data);
|
$currencyCode = $this->tryDecrypt((string)$currencyPreference->data);
|
||||||
$currency = TransactionCurrency::where('code', $currencyCode)->first();
|
|
||||||
|
// could still be json encoded:
|
||||||
|
if (\strlen($currencyCode) > 3) {
|
||||||
|
$currencyCode = null === json_decode($currencyCode) ? 'EUR' : $currencyCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
$currency = TransactionCurrency::where('code', $currencyCode)->first();
|
||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
throw new FireflyException(sprintf('No currency found with code "%s"', $currencyCode));
|
throw new FireflyException(sprintf('No currency found with code "%s"', $currencyCode));
|
||||||
}
|
}
|
||||||
@@ -288,4 +277,20 @@ class Amount
|
|||||||
'zero' => $positive,
|
'zero' => $positive,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private function tryDecrypt(string $value): string
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$value = Crypt::decrypt($value);
|
||||||
|
} catch (DecryptException $e) {
|
||||||
|
Log::debug(sprintf('Could not decrypt. %s', $e->getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user