mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Graceful decryption method
This commit is contained in:
parent
f185c2e0de
commit
e1229bfb0f
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue