mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 04:41:01 +00:00
Update packages and notification settings
This commit is contained in:
@@ -56,13 +56,13 @@ class FireflyConfig
|
||||
return null;
|
||||
}
|
||||
if ('' === $result->data) {
|
||||
Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));
|
||||
Log::warning(sprintf('Empty encrypted configuration value found: "%s"', $name));
|
||||
return $result;
|
||||
}
|
||||
try {
|
||||
$result->data = decrypt($result->data);
|
||||
} catch (DecryptException $e) {
|
||||
Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));
|
||||
Log::error(sprintf('Could not decrypt configuration value "%s": %s', $name, $e->getMessage()));
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
@@ -105,8 +105,8 @@ class FireflyConfig
|
||||
try {
|
||||
$encrypted = encrypt($value);
|
||||
} catch (EncryptException $e) {
|
||||
Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));
|
||||
throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));
|
||||
Log::error(sprintf('Could not encrypt configuration value "%s": %s', $name, $e->getMessage()));
|
||||
throw new FireflyException(sprintf('Could not encrypt configuration value "%s". Cowardly refuse to continue.', $name));
|
||||
}
|
||||
return $this->set($name, $encrypted);
|
||||
}
|
||||
|
||||
@@ -26,9 +26,12 @@ namespace FireflyIII\Support;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Contracts\Encryption\EncryptException;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
/**
|
||||
@@ -53,6 +56,37 @@ class Preferences
|
||||
;
|
||||
}
|
||||
|
||||
public function getEncrypted(string $name, $default = null): ?Preference
|
||||
{
|
||||
$result = $this->get($name, $default);
|
||||
if (null === $result) {
|
||||
return null;
|
||||
}
|
||||
if ('' === $result->data) {
|
||||
Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));
|
||||
return $result;
|
||||
}
|
||||
try {
|
||||
$result->data = decrypt($result->data);
|
||||
} catch (DecryptException $e) {
|
||||
Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setEncrypted(string $name, mixed $value): Preference
|
||||
{
|
||||
try {
|
||||
$encrypted = encrypt($value);
|
||||
} catch (EncryptException $e) {
|
||||
Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));
|
||||
throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));
|
||||
}
|
||||
return $this->set($name, $encrypted);
|
||||
}
|
||||
|
||||
|
||||
public function get(string $name, null|array|bool|int|string $default = null): ?Preference
|
||||
{
|
||||
/** @var null|User $user */
|
||||
|
||||
Reference in New Issue
Block a user