From cbe3fb73a88a0dbd246467d26e452e7537bbb65c Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 27 Jun 2016 16:36:28 +0200 Subject: [PATCH] Catch decrypt exceptions. --- app/Models/Preference.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Models/Preference.php b/app/Models/Preference.php index 44e5951cbf..cbb7b0512a 100644 --- a/app/Models/Preference.php +++ b/app/Models/Preference.php @@ -12,6 +12,8 @@ declare(strict_types = 1); namespace FireflyIII\Models; use Crypt; +use FireflyIII\Exceptions\FireflyException; +use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Database\Eloquent\Model; /** @@ -48,7 +50,11 @@ class Preference extends Model */ public function getDataAttribute($value) { - $data = Crypt::decrypt($value); + try { + $data = Crypt::decrypt($value); + } catch (DecryptException $e) { + throw new FireflyException('Could not decrypt preference #' . $this->id . '.'); + } return json_decode($data); }