Catch decrypt exceptions.

This commit is contained in:
James Cole 2016-06-27 16:36:28 +02:00
parent 3d58fbebec
commit cbe3fb73a8

View File

@ -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);
}