Skip to content

Commit 62bced9

Browse files
committed
fix: support non-encrypted values in EncryptedCaster
1 parent 0363cb6 commit 62bced9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/database/src/Casters/EncryptedCaster.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
namespace Tempest\Database\Casters;
66

7+
use Tempest\Cryptography\Encryption\EncryptedData;
78
use Tempest\Cryptography\Encryption\Encrypter;
9+
use Tempest\Cryptography\Encryption\Exceptions\EncryptionException;
810
use Tempest\Mapper\Caster;
11+
use Tempest\Support\Json\Exception\JsonException;
912

1013
final readonly class EncryptedCaster implements Caster
1114
{
@@ -19,6 +22,10 @@ public function cast(mixed $input): ?string
1922
return null;
2023
}
2124

22-
return $this->encrypter->decrypt($input);
25+
try {
26+
return $this->encrypter->decrypt($input);
27+
} catch (EncryptionException|JsonException) {
28+
return $input;
29+
}
2330
}
2431
}

0 commit comments

Comments
 (0)