Graceful decryption method

This commit is contained in:
snipe 2016-08-25 20:58:56 -07:00
parent f185c2e0de
commit e1229bfb0f

View file

@ -17,6 +17,8 @@ use App\Models\Component;
use App\Models\Accessory;
use App\Models\Consumable;
use App\Models\Asset;
use Crypt;
use Illuminate\Contracts\Encryption\DecryptException;
/*
* To change this license header, choose License Headers in Project Properties.
@ -476,6 +478,21 @@ class Helper
}
public static function gracefulDecrypt(CustomField $field, $string) {
if ($field->isFieldDecryptable($string)) {
try {
Crypt::decrypt($string);
return Crypt::decrypt($string);
} catch (DecryptException $e) {
return 'Error Decrypting: '.$e->getMessage();
}
}
return $string;
}
}